Skip to content

Introduce support for subplots #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vepadulano
Copy link

This commit introduces support for plotting multiple subplots in the same canvas. A new function aptly called subplots lets the user specify a grid layout in which to split the main canvas and returns an object through which the canvas and its subcomponents can be managed for plotting. Various configuration options are available, such as specifying extra space at the top or bottom of the canvas for extra pads which could host e.g. a shared common legend for all the subplots. Two new classes are also introduced. CMSCanvasManager is the type returned by the subplots function. It stores all the pads created and gives access to them. Each pad is of type CMSPad, the second main class introduced, which exposes a plot method to plot graphics onto that specific pad, without needing to interact with internal ROOT mechanisms such as gPad.

Fixes #52

Note that I have added a test and if I execute it locally I get the following image, let me know if it's well placed as is or I should touch somewhere else
cmsstyle_subplots

This commit introduces support for plotting multiple subplots in the
same canvas. A new function aptly called `subplots` lets the user
specify a grid layout in which to split the main canvas and returns an
object through which the canvas and its subcomponents can be managed for
plotting. Various configuration options are available, such as
specifying extra space at the top or bottom of the canvas for extra pads
which could host e.g. a shared common legend for all the subplots. Two
new classes are also introduced. CMSCanvasManager is the type returned
by the `subplots` function. It stores all the pads created and gives
access to them. Each pad is of type CMSPad, the second main class
introduced, which exposes a plot method to plot graphics onto that
specific pad, without needing to interact with internal ROOT mechanisms
such as gPad.

Fixes cms-cat#52

Co-authored-by: Tommaso Tedeschi <[email protected]>
Comment on lines +1946 to +1953
# This part here is still custom, needs an abstract definition in
# the function signature to provide the ranges of all the axes
if row_index % 2 == 0:
ymin = 0
ymax = 400
else:
ymin = 0
ymax = 2
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is the last hard-coded part. In principle we should think about adding an (optional) argument to the function so the user can provide the ranges of all axes (or just for the x and y axis once in case they are shared)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for multi-plot
1 participant