# 5.11.1.4. eqcorrscan.utils.plotting.freq_mag

`eqcorrscan.utils.plotting.``freq_mag`(magnitudes, completeness, max_mag, binsize=0.2, save=False, savefile=None)

  Plot a frequency-magnitude histogram and cumulative density plot.

  Currently this will compute a b-value, for a goiven completeness. B-value is computed by linear fitting to section of curve between completeness and max_mag.

  Parameters: | magnitudes (list) list of float of magnitudes completeness (float) Level to compute the b-value above max_mag (float) Maximum magnitude to try and fit a b-value to binsize (float) Width of histogram bins, defaults to 0.2 save (bool) False will plot to screen, true will save plot and not show to screen. savefile (str) Filename to save to, required for save=True
  Returns: | `matplotlib.figure.Figure`

  Note

  See `eqcorrscan.utils.mag_calc.calc_b_value()` for a least-squares method of estimating completeness and b-value. For estimating maximum curvature see `eqcorrscan.utils.mag_calc.calc_max_curv()`.

  Example

      >>> from obspy.clients.fdsn import Client
      >>> from obspy import UTCDateTime
      >>> from eqcorrscan.utils.plotting import freq_mag
      >>> client = Client('IRIS')
      >>> t1 = UTCDateTime('2012-03-26T00:00:00')
      >>> t2 = t1 + (3 * 86400)
      >>> catalog = client.get_events(starttime=t1, endtime=t2, minmagnitude=3)
      >>> magnitudes = [event.preferred_magnitude().mag for event in catalog]
      >>> freq_mag(magnitudes, completeness=4, max_mag=7)

  (Source code, png, hires.png)