Histograms¶
Documentation¶
- utilities.plotUtilities.asManyHists(numPlot, data, bins=None, weights=None, hideXlabel=False, hideYlabel=False, hideYticks=False, hideXticks=False, placeYaxisOnRight=False, xlabel='', ylabel='', color='black', label='', zorder=0, textsize=24, showLegend=False, legendTextSize=24, shadow=True, fancybox=True, framealpha=1, legendEdgeColor=None, frameon=True, xlim=[None, None], locLegend='best', tickSize=24, title='', titlesize=24, outputName=None, overwrite=False, tightLayout=True, integralIsOne=None, align='mid', histtype='stepfilled', alpha=1.0, cumulative=False, legendNcols=1, hatch=None, orientation='vertical', log=False, stacked=False, grid=True)[source]¶
Code author: Wilfried Mercier - IRAP <wilfried.mercier@irap.omp.eu>
Function which plots on a highly configurable subplot grid 1D histograms. A list of data can be given to have multiple histograms on the same subplot.
- Parameters
data (ndarray) – data to plot as histogram
numPlot (list[3 int] or ndarray[3 int] or int or matplotlib GridSpec instance) –
plot identifier. It can be
an int (format is XYZ with X the number of rows, Y the number of columns and Z the plot position)
a list with 3 similar numbers [X, Y, Z]
a matplotlib GridSpec instance
align (str) – (Optional) how to align bars with respect to their value. Must either be ‘left’, ‘mid’ or ‘right’.
alpha (float) – (Optional) transparency of the bars
bins (int or list[int]) –
(Optional) define the bins:
if an int, must be the number of bins
if a list, must be the bins edges
color (str) – (Optional) color for the data. It can either be a string or RGB values.
cumulative (bool) – (Optional) whether to plot the cumulative distribution (where each bin equals the sum of the values in the previous bins up to this one)
fancybox (bool) – (Optional) whether to draw a fancy legend or not
framealpha (float) – (Optional) transparency the legend background
frameon (bool) – (Optional) whether to draw the legend frame or not
grid (bool) – (Optional) whether to show the grid or not
hatch (str) – (Optional) hatching pattern
hideXlabel (bool) – (Optional) whether to hide the x label or not
hideXticks (bool) – (Optional) whether to hide the x ticks or not
hideYlabel (bool) – (Optional) whether to hide the y label or not
hideYticks (bool) – (Optional) whether to hide the y ticks or not
histtype (str) – (Optional) type of histogram. Must either be ‘bar’ (histograms next to each other), ‘barstacked’ (stacked histograms), ‘step’ (unfilled histograms) or ‘stepfilled’ (filled histograms).
integralIsOne (bool) – (Optional) whether to normalise the integral of the histogram
label (str) – (Optional) legend label
legendEdgeColor (str) – (Optional) color of the legend edges. If None, there is no edge.
legendNcols (int) – (Optional) number of columns in the legend
legendTextSize (int) – (Optional) size for the legend
locLegend (str) – (Optional) position of the legend
orientation (str) – (Optional) orientation of the bars
outputName (str) – (Optional) file name where save the figure. If None, the plot is not saved into a file.
overwrite (bool) – (Optional) whether to overwrite the ouput file or not
placeYaxisOnRight (bool) – (Optional) whether to place the y axis of the plot on the right or not
textsize (int) – (Optional) size for the labels
shadow (bool) – (Optional) whether to draw a shadow around the legend or not
showLegend (bool) – (Optional) whether to show the legend or not
tickSize (int) – (Optional) size of the ticks on both axes
tightLayout (bool) – (Optional) whether to use bbox_inches=’tight’ if tightLayout is True or bbox_inches=None otherwise
weights (ndarray[float]) – (Optional) weights to apply to each value in data
xlabel (str) – (Optional) x axis label
xlim (list[float]) – (Optional) x-axis limits to use. If None, data bounds are used.
ylabel (str) – (Optional) y axis label
ylim (list[floats]) – (Optional) y-axis limits to use. If None, data bounds are used
zorder (int) – (Optional) plot position. The lower the value, the earlier it will be plotted
- Returns
Current axis, hist values, bin values, patches elements and legend elements