clipt.plot¶
functions for plotting with matplotlib
-
clipt.plot.
tick_from_arg
(ax, xs, ys, a4, kwargs)[source]¶ sets ticks based on standard argument parsing
- Parameters
ax (matplotlib subplot) –
a4 (kwargs for ticks) –
kwargs (input arguments) –
- Returns
ax
- Return type
matplotlib subplot
-
clipt.plot.
get_user_labels
(labels, mlab)[source]¶ returns data based on standard argument parsing
- Parameters
labels (list) – labels returned by read_all_data
mlab (list) – manual labels for data
- Returns
labels – list of labels for each y_val
- Return type
list
-
clipt.plot.
get_labels
(dataf, labs, a1, ycnt, xheader=False, xlabels=None, labels=None, rows=False, drange=None, y_vals=[- 1], **kwargs)[source]¶
-
clipt.plot.
get_axes
(arg, xs, ys, polar=False, polarauto=True, stacked=False, pery=False, **kwargs)[source]¶ parse axes string argument xname,xmin,xmax,yname,ymin,ymax
-
clipt.plot.
plot_setup
(fg='black', bg='white', polar=False, areaonly=False, params={}, **kwargs)[source]¶ setup plot with uniform styling and create axes for plot
- Parameters
fg (color) – foreground color
bg (color) – background color
polar (bool) – if true make polar plot
params (dict) – rcParams to update
- Returns
ax (matplotlib sublot)
fig (matplotlib figure)
-
clipt.plot.
ticks
(ax, xdata=[0, 1], ydata=[0, 1], tcol='black', labels=['X', 'Y'], xgrid=True, ygrid=True, xscale='linear', yscale='linear', annualx=False, dayy=False, pery=False, ticklines=False, pph=1, bottom=None, bg='white', xlabels=None, dpy=365, hpd=24, sh=0, polar=False, xticks=None, yticks=None, labelweight='ultralight', matchxy=False, xrotate='a', **kwargs)[source]¶ setup ticks/axes for plot
- Parameters
ax (matplotlib sublot) –
xdata (list) – x data (or min and max)
ydata (list) – y data (or min and max)
tcol (color) – tick color
labels (list) – x and y axis labels
xgrid (bool) – show x grid
ygrid (bool) – show y grid
xscale (str) – linear or log
yscale (str) – linear or log
annualx (bool) – plot xaxis as full year with month labels
dayy (bool) – plot yaxis as day with hour labels
pery (bool/int) – if > 1 label y axis according to percentile of data with pery bins
ticklines (bool) – if not grid, show ticklines
-
clipt.plot.
plot_legend
(ax, handles, bbox_to_anchor=1.05, 1, loc=2, fg='black', bg='white', title=None)[source]¶ add legend to figure
-
clipt.plot.
add_colorbar
(fig, pc, axes=[0.3, 0.0, 0.4, 0.02], ticks=None, ticklabels=None, orientation='horizontal')[source]¶ add colorbar scale to figure below plot
-
clipt.plot.
plot_graph
(fig, saveimage, width=5, height=5, bg='white', fg='black', handles=[], handles2=[], dpi=200, bbox_to_anchor=1.05, 1, loc=2, legend=False, background=None, front=False, alpha=0.5, areaonly=False, polar=False, **kwargs)[source]¶ add legend and save image of plot
-
clipt.plot.
get_colors
(cmap, step=None, positions=None, funcs=[], **kwargs)[source]¶ get colormap from cmap name, color list or CliptColors spec
- Parameters
cmap (str or list of color tuples) – cmap selector
positions (list) – if cmap is a list positions are the mapping points else positions are the sample points used to remap
step (int or None) – # of steps to map colors using step function
funcs (list of custom color map functions to try before standard) – matplotlib cmap name check and cmap_from_list func should accept a cmap argument, and step and position (call cmap_tune within to utilize) and return a matplotlib.cm.ScalarMappable
- Returns
colormap
- Return type
matplotlib.colors.LinearSegmentedColormap
-
clipt.plot.
plot_cmaps
(ru=False)[source]¶ plot predefined colormaps showing impact of step and position
- Returns
fig – can be saved using plt.savefig(…) or plotutil.plot_graph(…)
- Return type
matplotlib graph
-
clipt.plot.
plot_criteria
(ax, x, y, criteria, flipxy=False, kwargs={'linewidth': 0, 'marker': 'o', 'markersize': 4, 'mew': 0})[source]¶ add dot on line matching criteria to scatter plot
-
clipt.plot.
plot_scatter
(fig, ax, xs, ys, labels, colormap, criteria=None, lw=2, ms=0, mrk='o', step=None, fcol=0.0, mew=0.0, emap=None, estep=None, flipxy=False, cs=None, cmin=None, cmax=None, y2=None, msd=None, mmin=None, mmax=None, legend=True, polar=False, areas=[], falpha=0.5, **kwargs)[source]¶ adds scatterplots/lines to ax and returns ax and handles for legend
-
clipt.plot.
plot_heatmap
(fig, ax, data, colormap, vmin=None, vmax=None, dst=False, ticks=None, labels=None, legend=True, hpd=24, dpy=365, sh=0, **kwargs)[source]¶ adds heatmap and colorbar to ax returns ax
-
clipt.plot.
plot_bar
(ax, xs, ys, labels, colormap, stacked=False, rwidth=0.8, step=None, estep=None, bwidth=0.9, fcol=0.0, brng=[0, 1], bottom=0, polar=False, polar0=False, emap=None, ew=[0], **kwargs)[source]¶ adds bar plots to ax and returns ax and handles for legend
-
clipt.plot.
plot_box
(ax, data, labels, colormap, ylim, rwidth=0.8, step=None, mark='x', whis=1.5, mew=0.5, ms=3.0, lw=1.0, fcol=0.0, clw=1.0, clbg=True, fillalpha=1.0, notch=False, series=1, sgap=0.5, bg='white', inline=False, mean=False, fliers=True, xlabels=None, **kwargs)[source]¶ adds box plots to ax and returns ax and handles for legend
-
clipt.plot.
kernel
(d, w=None, mi=None, mx=None, n=1000, t=0.0001, bws=0.5)[source]¶ prepare a gaussian kernel
bws is a scale factor to the bw_method
gaussian kernel selection by Scott’s rule, see: https://docs.scipy.org/doc/scipy/reference/generated/ scipy.stats.gaussian_kde.html
-
clipt.plot.
quant_box
(x, w=None, ci=0.75, ciw=0.95)[source]¶ create box and whiskers for weighted data
-
clipt.plot.
conf_box
(x, w=None, ci=0.75, ciw=0.95, nsamp=100, t=0.0)[source]¶ bootstrap a confidence interval for the mean of a weighted sample
-
clipt.plot.
plot_violin
(ax, data, labels, colormap, ylim, rwidth=0.8, step=None, lw=1.0, kernelwidth=0.5, clw=1.0, clbg=True, fcol=0.0, fillalpha=1.0, median=True, conf=None, confm=None, series=1, bg='white', inline=False, mean=False, weights=None, weightlimit=0.0, fliers=False, **kwargs)[source]¶ adds violin plots to ax and returns ax and handles for legend
-
clipt.plot.
plot_histo
(ax, data, labels, colormap, ylim, stacked=False, rwidth=0.8, step=None, fcol=0.0, bwidth=0.9, bins='auto', brange=None, tails=False, ylog=False, density=False, weights=None, **kwargs)[source]¶ adds histo plots to ax and returns ax and handles for legend
-
clipt.plot.
shift_data
(data, pph=1, sa=3, 10, fb=11, 2, hpd=24, dpy=365, sh=0)[source]¶ shift annual data for DST for correct hour axis on heatmap
- Parameters
data (list) – length 8760*pph
pph (int) – data points per hour in data.
sa (tuple of ints) – (month, day) for spring ahead
fb (tuple of ints) – (month, day) for fall back
- Returns
data2 – data with 2AM on “spring ahead” duplicated and 1AM on “fall back” deleted
- Return type
list
-
clipt.plot.
get_tick_distribution
(data, divisions)[source]¶ returns values demarcating equal size bins on data
- Parameters
data (list) – list of float values
divisions (int) – number of divisions to make (cannot exceed len(data))
- Returns
ticks – values from data at each division point
- Return type
list
-
clipt.plot.
pad_scale
(data, n=8760, mult=1, missing=0.0)[source]¶ scale and pad data returns numpy.array
-
clipt.plot.
ticks_x_annual
(ax, fg='black', dpy=365)[source]¶ set xaxis to days in year with month labels
-
clipt.plot.
ticks_y_per
(ax, ydata, tickdiv, tcol='black')[source]¶ label y axis according to percentile of data with pery bins
-
clipt.plot.
cmap_from_list
(cmap, step=None, positions=None, name='custom')[source]¶ return colormap from list of colors
-
clipt.plot.
cmap_from_mpl
(cmap, step=None, positions=None)[source]¶ return colormap from matplotlib colormaps