mmfutils.plot

Plotting utilities for matplotlib.

mmfutils.plot.contourf(*v, **kw)[source]

Replacement for matplotlib.pyplot.contourf() that supports the rasterized keyword.

mmfutils.plot.imcontourf(x, y, z, interpolate=True, diverging=False, *v, **kw)[source]

Like matplotlib.pyplot.contourf() but does not actually find contours. Just displays z using matplotlib.pyplot.imshow() which is much faster and uses exactly the information available.

Parameters:
  • y, z (x,) – Assumes that z is ordered as z[x, y]. If x and y have the same shape as z, then x = x[:, 0] and y = y[0, :] are used. Otherwise, z.shape == (len(x), len(y)). x and y must be equally spaced.
  • interpolate (bool) – If True, then interpolate the function onto an evenly spaced set of abscissa using cublic splines.
  • diverging (bool) – If True, then the output is normalized so that diverging colormaps will have 0 in the middle. This is done by setting vmin and vmax symmetrically.
mmfutils.plot.phase_contour(x, y, z, N=10, colors='k', linewidths=0.5, **kw)[source]

Specialized contour plot for plotting the contours of constant phase for the complex variable z. Plots 4*N contours in total. Note: two sets of contours are returned, and, due to processing, these do not have the correct values.

The problem this solves is that plotting the contours of np.angle(z) gives a whole swath of contours at the discontinuity between -pi and pi. We get around this by doing two things:

  1. We plot the contours of abs(angle(z)). This almost fixes the problem, but can give rise to spurious closed contours near zero and pi. To deal with this:
  2. We plot only the contours between pi/4 and 3*pi/4. We do this twice, multiplying z by exp(0.5j*pi).
  3. We carefully choose the contours so that they have even spacing.
mmfutils.plot.plot_errorbars(x, y, dx=None, dy=None, colour='', linestyle='', pointstyle='.', barwidth=0.5, **kwargs)[source]
mmfutils.plot.plot_err(x, y, yerr=None, xerr=None, **kwarg)[source]

Plot x vs. y with errorbars.

Right now we support the following cases: x = 1D, y = 1D

mmfutils.plot.error_line(x, y, dy, fgc='k', bgc='w', N=20, fill=True)[source]

Plots a curve (x, y) with gaussian errors dy represented by shading out to 5 dy.

mmfutils.plot.MidpointNormalize