{"id":23610039,"url":"https://github.com/riley-x/root_plotting_tools","last_synced_at":"2025-11-05T23:30:22.324Z","repository":{"id":173083173,"uuid":"650213289","full_name":"riley-x/ROOT_Plotting_Tools","owner":"riley-x","description":"Framework for plotting in pyROOT with a declarative syntax","archived":false,"fork":false,"pushed_at":"2024-05-31T18:43:07.000Z","size":1339,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-27T15:15:44.780Z","etag":null,"topics":["declarative","plotting","pyroot","root-cern"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/riley-x.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-06T15:28:38.000Z","updated_at":"2024-05-31T18:43:10.000Z","dependencies_parsed_at":"2023-10-20T04:00:27.673Z","dependency_job_id":"804c6d08-567f-48a4-8e4a-5a3550d71267","html_url":"https://github.com/riley-x/ROOT_Plotting_Tools","commit_stats":null,"previous_names":["riley-x/root_plotting_tools"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riley-x%2FROOT_Plotting_Tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riley-x%2FROOT_Plotting_Tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riley-x%2FROOT_Plotting_Tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riley-x%2FROOT_Plotting_Tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riley-x","download_url":"https://codeload.github.com/riley-x/ROOT_Plotting_Tools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239475964,"owners_count":19645041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["declarative","plotting","pyroot","root-cern"],"created_at":"2024-12-27T15:15:47.157Z","updated_at":"2025-11-05T23:30:22.234Z","avatar_url":"https://github.com/riley-x.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Declarative ROOT Plotting Framework\n\nPlotting in ROOT is really annoying. You have to remember to call `\"SAME\"` everywhere,\naxis limits are highly unintuitive, and so on. This module attempts to make ROOT\nplotting easier through a declarative syntax. Typical usage would look like:\n\n```py\nimport plot\nplot.plot([h1, h2],                         # plots two histograms in the same canvas\n    opts = ['HIST', 'PE'],                  # plot h1 in 'HIST' format and h2 in 'PE' format\n    linecolor = plot.colors.tableu,         # sets each histogram's line color using a MPL colormap\n    linewidth = 3,                          # applied to both histograms\n    subtitle = '#sqrt{s} = 13 TeV^{-1}',    # text options can accept TLatex formatters\n    legend = ['Hist 1', 'Hist 2'],\n    ytitle = 'Events',\n    xtitle = 'm_{T}(W) [GeV]',\n    yrange = [0, None],                     # the yrange's upper end will be automatically adjusted to \n                                            # fit all data and ensure the title doesn't overlap the plot\n    filename = 'my_plot',\n)\n```\n\nThe input also doesn't have to be all histograms, you can include TF1s and TGraphs too.\nIn addition, this script takes care of several things missing in ROOT: automatic axis\nranges, automatic legend placement, title text and subtext, etc. It also defines helper\nfunctions to make some common plot types, like ratio plots.\n\n**Please see the docstring in `plot.py` for a full list of functions and options.**\n\n## Installation\n\nJust copy the `plot.py` file to your working directory and call\n```py\nimport plot\n```\n\nAlternatively, you can clone/submodule this repo:\n```sh\ngit submodule add git@github.com:riley-x/ROOT_Plotting_Tools.git rplottools\n```\nAnd in your python script:\n```py\nfrom rplottools import plot\n```\n\n## Saving Images\n\nThe format of the saved image is inferred by ROOT based on the extension in the filename.\nIf the extension is omitted, the canvas will be saved for each extension listed in\n`plot.file_formats`. This is convenient to save all your plots as both pdfs and pngs by default, \nfor example by specifying:\n```py\nplot.file_formats = ['png', 'pdf']\n```\nThis module can also save transparent pngs, which is enabled by setting\n```py\nplot.save_transparent = True\n```\nYou will need to have PIL installed.\n\n\n## Utilities\n\nThe `colors` class defines many useful colors and some Matplotlib colormaps, which can be\naccessed easily as direct names `plot.colors.blue`, or as indexing functions `plot.colors.tableu(0)`. See the docstring for the class for more info.\n\nA variety of other utility funcitons are also included in this module, such as normalizing histograms\nor rebinning a 2D histogram with variable bins.\n\n## Examples\n\n### Basic Plot\n\n[Source](./examples/basic_plot.py). Quick example showing how to style histograms, add title text, and set legend labels.\n\n\u003cimg src=\"./examples/basic_plot.png\" style=\"max-height: 3in\"\u003e\n\n\n\n### Ratio Plot\n\n[Source](./examples/ratio_plot.py). Example with more complicated formatting and legend, with a ratio subplot.\n\n\u003cimg src=\"./examples/ratio_plot.png\" style=\"max-height: 3in\"\u003e\n\n\n\n### Stack Plot\n\n[Source](./examples/stack_plot.py). Showcases both the 'stack' option and how to use the low-level plotter class \nto do some advanced formatting.  \n\n\u003cimg src=\"./examples/stack_plot.png\" style=\"max-height: 3in\"\u003e\n\n\n\n### Discrete Plot\n\n[Source](./examples/discrete_plot.py). This script showcases both `plot_discrete_bins()`, which plots histograms discretized in equal-width bins, and `plot_ratio3()`, which adds two subplots beneath the main plot.\n\n\u003cimg src=\"./examples/discrete_plot.png\" style=\"max-height: 3in\"\u003e\n\n\n\n\n### Tiered Plot\n\n[Source](./examples/tiered_plot.py). This script showcases `plot_tiered()`, which plots multiple histograms in several top-to-bottom tiers. This style is useful for comparing multiple distribution shapes without crowding the plot, at the cost of obscuring the relative normalizations.\n\n\u003cimg src=\"./examples/tiered_plot.png\" style=\"max-height: 3in\"\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friley-x%2Froot_plotting_tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friley-x%2Froot_plotting_tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friley-x%2Froot_plotting_tools/lists"}