# plotutil - Plotting utilities¶

 auto_shift Return a y-offset coordinate transform for the current axes. coordinated_colors Return a set of coordinated colors as c[‘base|light|dark’]. dhsv Modify color on hsv scale. next_color Return the next color in the plot color cycle. plot_quantiles Plot quantile curves for a set of lines. form_quantiles Return quantiles and values for a list of confidence intervals.

Pylab plotting utilities.

bumps.plotutil.auto_shift(offset)[source]

Return a y-offset coordinate transform for the current axes.

Each call to auto_shift increases the y-offset for the next line by the given number of points (with 72 points per inch).

Example:

from matplotlib import pyplot as plt
from bumps.plotutil import auto_shift
trans = auto_shift(plt.gca())
plot(x, y, trans=trans)

bumps.plotutil.coordinated_colors(base=None)[source]

Return a set of coordinated colors as c[‘base|light|dark’].

If base is not provided, use the next color in the color cycle as the base. Light is bright and pale, dark is dull and saturated.

bumps.plotutil.dhsv(color, dh=0.0, ds=0.0, dv=0.0, da=0.0)[source]

Modify color on hsv scale.

dv change intensity, e.g., +0.1 to brighten, -0.1 to darken. dh change hue ds change saturation da change transparency

Color can be any valid matplotlib color. The hsv scale is [0,1] in each dimension. Saturation, value and alpha scales are clipped to [0,1] after changing. The hue scale wraps between red to violet.

Make sea green 10% darker:

>>> from bumps.plotutil import dhsv
>>> darker = dhsv('seagreen', dv=-0.1)
>>> print([int(v*255) for v in darker])
[37, 113, 71, 255]

bumps.plotutil.next_color()[source]

Return the next color in the plot color cycle.

Example:

from matplotlib import pyplot as plt
from bumps.plotutil import next_color, dhsv
color = next_color()
plt.errorbar(x, y, yerr=dy, fmt='.', color=color)
# Draw the theory line with the same color as the data, but darker
plt.plot(x, y, '-', color=dhsv(color, dv=-0.2))

bumps.plotutil.plot_quantiles(x, y, contours, color, alpha=None)[source]

Plot quantile curves for a set of lines.

x is the x coordinates for all lines.

y is the y coordinates, one row for each line.

contours is a list of confidence intervals expressed as percents.

color is the color to use for the quantiles. Quantiles are draw as a filled region with alpha transparency. Higher probability regions will be covered with multiple contours, which will make them lighter and more saturated.

alpha is the transparency level to use for all fill regions. The default value, alpha=2./(#contours+1), works pretty well.

bumps.plotutil.form_quantiles(y, contours)[source]

Return quantiles and values for a list of confidence intervals.

contours is a list of confidence interfaces [a, b,…] expressed as percents.

Returns:

quantiles is a list of intervals [[a_low, a_high], [b_low, b_high], …] in [0,1].

values is a list of intervals [[A_low, A_high], …] with one entry in A for each row in y.