mmfutils.plot.colors

Various tools for displaying information with color.

class mmfutils.plot.colors.MidpointNormalize(vmin=None, vmax=None, clip=False, midpoint=0)[source]

Bases: Normalize

Colormap normalization that ensures a balanced distribution about the specified midpoint.

Use this with a diverging colormap to ensure that the midpoint lies in the middle of the colormap.

Examples

>>> norm = MidpointNormalize(midpoint=1.0)
>>> norm(np.arange(4))
masked_array(data=[0.25, 0.5 , 0.75, 1. ],
             mask=False,
       fill_value=1e+20)
>>> norm = MidpointNormalize(midpoint=1.0, vmin=-3)
>>> norm(np.arange(4))
masked_array(data=[0.375, 0.5 , 0.625, 0.75 ],
             mask=False,
       fill_value=1e+20)
autoscale_None(A)[source]

Sets vmin and vmax if they are None.

mmfutils.plot.colors.color_angle(theta, map='huslp', gamma=1, saturation=100.0, lightness=75.6)[source]

Return an RGB tuple of colors for each angle theta.

The colors cycle smoothly through all hues in the order of the rainbow. The default map is luminosity corrected:

http://www.husl-colors.org

Parameters:
  • theta (array) – Array of angles as returned, for example, by np.angle.

  • map ('husl' or 'hue') –

    Colour map to use.

    ’huslp’ :

    a luminosity corrected coloring. All angles here have the same perceptual brightness, however only pastel colors are used.

    ’husl’ :

    a luminosity corrected coloring similar to huslp but allowing for full saturation. Highly saturated colors do not appear to change uniformly though.

    other :

    a custom but poor cycling through hue.

mmfutils.plot.colors.color_complex(psi, vmin=None, vmax=None, reversed=False, **kw)[source]

Return RGB tuple of colors for each complex value.

Uses color_angle but varies the lightness to match the magnitude of psi.

Parameters:
  • vmin (float) – Minimum and maximum of magnitude range. Uses min and max of abs(phi) if not provided.

  • vmax (float) – Minimum and maximum of magnitude range. Uses min and max of abs(phi) if not provided.

  • reversed (bool) – If True, then the minimum magnitude is white.