sluyspy.plot module
Plot functions for the sluyspy package.
- sluyspy.plot.arrow_head_between_points(ax, xx, yy, dx=0, dy=0, scale=1, **kwargs)[source]
Plot an arrow head between two 2D points.
- Parameters:
ax (axes) – Axes object to plot on.
xx (float) – Array with two x values, for arrow-head position and direction.
yy (float) – Array with two y values, for arrow-head position and direction.
dx (float) – Shift arrow head in x direction.
dy (float) – Shift arrow head in y direction.
scale (float) – Scale arrow head.
- sluyspy.plot.hist_norm(obj, x, bins=None, range=None, density=False, weights=None, cumulative=False, bottom=None, histtype='bar', align='mid', orientation='vertical', rwidth=None, log=False, color=None, label=None, stacked=False, *, data=None, **kwargs)[source]
Draw a histogram normalised by total number rather than probability density.
- Parameters:
obj (pyplot object) – Pyplot object or axes object to plot to.
x (array or sequence of arrays) – Data.
bins (int or sequence or str) – Number of bins. Default: rcParams[“hist.bins”] (default: 10).
range (tuple or None) – Bin range, default: None.
density (bool) – Plot probability density. Default: False.
weights (array-like or None) – Weights. Default: None.
cumulative (bool or -1) – Plot a cumulative histogram. Default: False.
bottom (array-like, scalar, or None) – Location of the bottom of the bins. Default: None.
histtype (str) – Histogram type: {‘bar’, ‘barstacked’, ‘step’, ‘stepfilled’}, default: ‘bar’.
align (str) – Bin alignment: {‘left’, ‘mid’, ‘right’}, default: ‘mid’.
orientation (str) – Bin orientation: {‘vertical’, ‘horizontal’}, default: ‘vertical’.
rwidth (float or None) – The relative width of the bars as a fraction of the bin width, default: None.
log (bool) – Set the histogram axis to a log scale, default: False.
color (color or array-like of colors or None) – Color or sequence of colors for bins, one per dataset, default: None.
label (str or None) – Legend label, default: None.
stacked (bool) – Stack multiple data on top of each other, rather than side by side, default: False.
data (indexable object, optional) – If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception): x, weights.
- Returns:
Tuple consisting of (n, bin_edges, patches):
(array or list of arrays): The values of the histogram bins.
(array): The edges of the bins. Length nbins + 1.
(BarContainer or list of Polygons): (List of) container(s) of individual artists used to create the histogram(s).
- Return type:
(tuple)
- sluyspy.plot.pause_ctrlc(interval)[source]
Call pyplot.pause() and catch Ctrl-C to exit gently.
- Parameters:
interval (float) – pause time in seconds.
- sluyspy.plot.start_plot(ptype='both', hsize=None, vsize=None, dark_bg=False, xkcd=False, title='Python plot', fz=None, lw=None, plot3d=False, man_zorder=True)[source]
Start a matplotlib.pyplot plot with a choice of my favourite options.
- Parameters:
ptype (str) – Plot type: ‘screen’, ‘file’, ‘both’ (a compromise) or ‘square’.
hsize (float) – Horizontal size of the figure (hectopixels); can overrule setting by ptype.
vsize (float) – Vertical size of the figure (hectopixels); can overrule setting by ptype.
dark_bg (bool) – Use a dark background (optional, defaults to False).
xkcd (bool) – Use XKCD style (optional, defaults to False).
title (str) – Window title (optional, defaults to ‘Python plot’).
fz (int) – Font size (optional, defaults to None -> 14 or 16).
lw (int) – Line width (optional, defaults to None -> 1 or 2).
plot3d (bool) – Start a 3D plot (optional, defaults to False -> 2D).
map_zorder (bool) – Use manual zorder (defaults to True - opposed to pyplot default: compute).
- Returns:
Tuple containing the plot and axis objects.
- Return type:
(tuple)
- Defaults:
screen: size 1920x1080, font 14, lw: 1;
file: size 1250x700, font 14, lw: 2;
both: size 1580x850, font 16, lw: 2;
square: size 850x850, font 16, lw: 2.