Miscellaneous
Creating a grid of plots
Casys Tools offers a
create_image_grid()
utility
function to put a set of CasysPlot
and/or images
together as a grid.Build an image containing all provided plots in as a grid of plots.
Parameters
----------
figure_size
Figure size (width, height).
plots
List of CasysPlots or/and images path.
rows_nb
Number of rows in the grid.
columns_nb
Number of columns in the grid.
save_path
Save individual plot in the specified directory.
dpi
Resulting image dpi.
kwargs
Additional parameters passed to the pyplot's figure method.
Returns
-------
:
Matplotlib figure containing everything.
from casys import CasysPlot, create_image_grid
plot1 = CasysPlot(data=ad, data_name="SIG0 pass", stat="mean")
plot2 = CasysPlot(data=ad, data_name="SIG0 pass", stat="std")
plot3 = CasysPlot(data=ad, data_name="SLA pass", stat="mean")
plot4 = CasysPlot(data=ad, data_name="SLA pass", stat="std")
fig = create_image_grid(
figure_size=(14.5, 9),
plots=[plot1, plot2, plot3, plot4],
columns_nb=2,
)
fig

The object returned by this function is a Matplotlib
Figure
and can be used as such once created.
Manually customizing figures
The main graphic is the first
axes
of the figure.
Following axes are the additional bars in their addition order.from casys import CasysPlot, PlotParams
plot = CasysPlot(
data=ad,
data_name="SIG0 (6h)",
stat="mean",
plot_params=PlotParams(fig_width=8, fig_height=5, y_limits=(8, 17))
)
plot.add_stat_bar(position="top")
plot.show()
fig = plot.figure
fig.suptitle("New title")
ax = fig.axes[0]
ax.grid()
ax.set_ybound(12.5, 15.5)
ax.lines[0].set_marker('.')
ax.lines[0].set_markersize(15)
ax.lines[0].set_linestyle('--')
plot.show()

Storing and loading
CasysPlot
objects can be stored and loaded in order to be shared or reused
without having to read, configure or compute everything again.Storing method
Store this CasysPlot object into a pickle format.
Parameters
----------
name
Name and path of the file.
overwrite
Whether to overwrite any existing file or not.
Example
from casys import CasysPlot
plot = CasysPlot(data=ad, data_name="SIG0 (6h)", stat="mean")
plot.store("plot.back", overwrite=True)
Loading method
Load a previously stored CasysPlot object.
Parameters
----------
name
Name and path of the file.
Returns
-------
:
The loaded object.
Example
from casys import CasysPlot
loaded_plot = CasysPlot.load("plot.back")
loaded_plot.show()

Resetting a plot
CasysPlots might be reset to their original state using the
reset()
method.All added elements or merged plots will be removed and parameters set back to the ones
used during the initialisation.
Reinitialize this plot by removing anything previously added to
it.