Plotting¶
As an attempt to make plotting in Python easier, we are building a plotting library that attempts to solve the more specific plotting needs when working with high energy physics. The first plotting tool we have is to reproduce ROOT’s LEGO plot, but more will come in the future.
- PyPWA.make_lego(x_data, y_data, bins=None, cmap='jet', ax=None, elev=10, azim=215)¶
Produces a 3D Lego plot, similar to what is produced by ROOT. This is similar to a 2D Histogram, but treats x and y as x and z, and projects the occurrences into the y dimension.
- Parameters
x_data (ndarray or Series) – X data for the lego plot
y_data (ndarray or Series) – Y data for the lego plot
bins (int, optional) – Number of bins to create when making the lego plot.
cmap (str or matplotlib.colors.ListedColormap, optional) – cmap to use when creating the lego plot. It takes either a string of the name for matplotlib, or a matplotlib cmap
ax (Axes3D, optional) – An axes object to place the lego plot into. The axes must be an axes that supports 3d projection or it will cause the function to error.
elev (int, optional) – Adjusts the elevation of the lego-plot
azim (int, optional) – Adjusts the azimuth of the resulting image. It’s value is a angle between 0 and 360 degrees.
- Returns
The axes object of the plot
- Return type
Axes3D
Notes
If the number of bins isn’t provided, it’s instead calculated using one half of Sturge’s Rule rounded up:
\[\lceil (1/2)(1 + 3.322 \cdot log(N_{events})\rceil\]