8#include <TGraphErrors.h>
72 const TString title =
"");
79 const TString title =
"");
86 const TString title =
"");
99 const TString title =
"");
112 const TString title =
"");
126 const TString title =
"");
139 const TString title =
"");
183 Int_t legend_width_px = 600,
184 Int_t plot_height_px = 800,
185 Bool_t logy = kFALSE);
211 TPad *&upper, TPad *&lower);
242 static void SaveFigure(TCanvas *canvas, TString output_filename,
243 TString output_subdirectory =
"",
288 const std::vector<TGraph *> &component_graphs,
289 Float_t fit_range_low, Float_t fit_range_high,
290 const TString &output_name,
291 const TString &output_subdirectory =
"fits",
292 const TString &label =
"", Bool_t logy = kTRUE);
308 static TLegend *
AddLegend(Double_t x1 = 0.7, Double_t x2 = 0.9,
309 Double_t y1 = 0.7, Double_t y2 = 0.9);
325 static Double_t
TextWidthPx(
const TString &text, Double_t size_px = 30.0,
346 static Double_t
LegendWidthPx(
const std::vector<TString> &labels,
347 const TString &header =
"",
348 Double_t size_px = 30.0, Double_t margin = 0.25,
349 Double_t padding_px = 15.0);
369 Int_t reference_width_px = 1200);
392 static void ScaleFigure(TVirtualPad *pad, Int_t reference_width_px = 1200,
393 Int_t reference_height_px = 800);
411 static void ScalePad(TVirtualPad *pad, Double_t scale,
412 Int_t reference_width_px = 1200,
413 Int_t reference_height_px = 800);
437 Double_t scale = 1.0,
438 Int_t reference_width_px = 1200,
439 Int_t reference_height_px = 800);
447 static void ScaleLegend(TLegend *legend, Double_t scale);
463 static void ScaleText(TText *text, TVirtualPad *pad, Double_t scale,
464 Int_t reference_height_px = 800);
483 static TLatex *
DrawTitle(TVirtualPad *pad,
const TString &title,
484 Double_t scale = 1.0);
494 static void ScaleLine(TAttLine *line, Double_t scale);
503 static void ScaleMarker(TAttMarker *marker, Double_t scale);
518 static TLatex *
AddText(
const TString label, Double_t x = 0.9,
519 Double_t y = 0.85, Double_t angle = 0);
541 static Bool_t preferences_set_;
542 static Width_t line_width_;
543 static TString plots_base_dir_;
544 static void SetTurboPalette();
545 static void WarnIfNotConfigured(
const TString method_name);
546 static void PlotPullHistogram(TGraph *residuals,
const TString &output_name,
547 const TString &output_subdirectory);
PlotSaveOptions
Which axis scalings SaveFigure() should write out.
@ kBOTH
Both, as two separate files.
@ kLOG
Logarithmic y only, written with a log_ filename prefix.
PlotSaveFormat
Output file format for saved figures.
@ kPNG
PNG raster output; line width 2.
@ kPDF
PDF vector output; line width 1.
All-static helpers for publication-quality ROOT graphics.
static TLatex * AddText(const TString label, Double_t x=0.9, Double_t y=0.85, Double_t angle=0)
Create and draw a text annotation on the current pad.
static void ConfigureAndDrawGraph(TGraph *graph, Int_t color, const TString title="")
ConfigureGraph() followed by Draw().
static TLegend * AddLegend(Double_t x1=0.7, Double_t x2=0.9, Double_t y1=0.7, Double_t y2=0.9)
Create, style and draw a legend on the current pad.
static void SaveFigure(TCanvas *canvas, TString output_filename, TString output_subdirectory="", PlotSaveOptions save_options=PlotSaveOptions::kBOTH)
Write a canvas to disk under the configured plots base directory.
static void SetPlotsBaseDir(const TString &dir)
Set the base directory that saved figures are written under.
static TString GetRandomName()
Generate a name unlikely to collide with existing ROOT objects.
static TLatex * DrawTitle(TVirtualPad *pad, const TString &title, Double_t scale=1.0)
Draw a figure title centred in a pad's top margin, at the size ROOT's own pad title has on the standa...
static void ConfigureGraph(TGraph *graph, Int_t color, const TString title="")
Apply the preferred style to a graph without drawing it.
static void ScaleLegend(TLegend *legend, Double_t scale)
Set a legend's text to AddLegend()'s 30 px times a scale.
static void SetStylePreferences(PlotSaveFormat save_format=PlotSaveFormat::kPNG)
Install the global ROOT style and choose the output format.
static void Configure2DHistogram(TH2 *hist, TCanvas *canvas, const TString title="")
Apply the preferred style to a 2-D histogram and its canvas.
static void ConfigureAndDrawHistogram(TH1 *hist, Int_t color, const TString title="")
ConfigureHistogram() followed by Draw("HIST").
static void ConfigureHistogram(TH1 *hist, Int_t color, const TString title="")
Apply the preferred style to a 1-D histogram without drawing it.
static TCanvas * GetConfiguredCanvasWithSideLegend(TPad *&plot, TPad *&legend_pad, Int_t legend_width_px=600, Int_t plot_height_px=800, Bool_t logy=kFALSE)
A canvas with the standard plot area and a legend pad to its right.
static Double_t LegendWidthPx(const std::vector< TString > &labels, const TString &header="", Double_t size_px=30.0, Double_t margin=0.25, Double_t padding_px=15.0)
Width a legend box needs for its labels at AddLegend()'s font.
static TCanvas * GetConfiguredCanvas(Bool_t logy=kFALSE)
Create a 1200x800 canvas with grid and ticks already set up.
static Double_t FigureScale(TVirtualPad *pad, Int_t reference_width_px=1200)
How much larger a pad is than the standard plot area, by width.
static void ScaleLine(TAttLine *line, Double_t scale)
Multiply a line width by a scale, rounded to a whole pixel.
static void ScaleText(TText *text, TVirtualPad *pad, Double_t scale, Int_t reference_height_px=800)
Scale a text object with its pad.
static void SplitPadForPanel(TVirtualPad *pad, Int_t panel_height_px, TPad *&upper, TPad *&lower)
Split a pad into a main pad above and a panel below, leaving the main pad's frame exactly as it would...
static Double_t TextWidthPx(const TString &text, Double_t size_px=30.0, Int_t font=43)
Rendered width of a text in a pixel-sized font.
static Width_t GetLineWidth()
Line width the Configure* methods apply.
static void PlotFitWithResiduals(TH1 *hist, TGraph *total_graph, const std::vector< TGraph * > &component_graphs, Float_t fit_range_low, Float_t fit_range_high, const TString &output_name, const TString &output_subdirectory="fits", const TString &label="", Bool_t logy=kTRUE)
Draw a fit over its data with a residual panel and save it.
static std::vector< Int_t > GetDefaultColors()
A palette of visually distinct ROOT colour indices.
static void ScaleFigure(TVirtualPad *pad, Int_t reference_width_px=1200, Int_t reference_height_px=800)
Scale everything on a pad, and its sub-pads, to print like the standard figure.
static void ScaleAxisFontsToPad(TH1 *frame, TVirtualPad *pad, Double_t scale=1.0, Int_t reference_width_px=1200, Int_t reference_height_px=800)
Size a frame's axis text as on the standard canvas, times a scale.
static void ScalePad(TVirtualPad *pad, Double_t scale, Int_t reference_width_px=1200, Int_t reference_height_px=800)
Scale one pad and everything drawn on it, recursively.
static void ScaleMarker(TAttMarker *marker, Double_t scale)
Multiply a marker size by a scale.
static void ConfigureAndDraw2DHistogram(TH2 *hist, TCanvas *canvas, const TString title="")
Configure2DHistogram() followed by Draw("COLZ").
static TString GetPlotsBaseDir()
Current base directory for saved figures, without trailing slash.