EW: provides centralized styling utilities for plots, including name prettification and style application.
More...
#include <Plotting/plottingUtils/styleManager.h>
|
std::string | prettifyName (const std::string &origName, const std::string &nameType) const |
|
EW: provides centralized styling utilities for plots, including name prettification and style application.
- Author
- Ewan Miller
Definition at line 20 of file styleManager.h.
◆ StyleManager() [1/3]
MaCh3Plotting::StyleManager::StyleManager |
( |
std::string |
configName | ) |
|
Constructor.
- Parameters
-
configName | The style config to read from |
Definition at line 4 of file styleManager.cpp.
#define M3OpenConfig(filename)
Macro to simplify calling LoadYaml with file and line info.
◆ StyleManager() [2/3]
MaCh3Plotting::StyleManager::StyleManager |
( |
const StyleManager & |
| ) |
|
|
delete |
◆ StyleManager() [3/3]
MaCh3Plotting::StyleManager::StyleManager |
( |
StyleManager && |
| ) |
|
|
default |
◆ ~StyleManager()
MaCh3Plotting::StyleManager::~StyleManager |
( |
| ) |
|
|
inline |
◆ prettifyName()
std::string MaCh3Plotting::StyleManager::prettifyName |
( |
const std::string & |
origName, |
|
|
const std::string & |
nameType |
|
) |
| const |
|
private |
Definition at line 8 of file styleManager.cpp.
9 YAML::Node prettyNames =
_styleConfig[
"PrettyNames"][nameType];
10 auto prettyName = GetFromManager<std::string>(prettyNames[origName], origName, __FILE__, __LINE__);
◆ prettifyParamName()
std::string MaCh3Plotting::StyleManager::prettifyParamName |
( |
const std::string & |
origName | ) |
const |
|
inline |
Convert hideous and vulgar internal parameter name into a beautiful presentable name.
The pretty parameter names should be specified in the style config file
- Parameters
-
origName | The "internal" name used to uniquely identify the parameter inside the plotting code |
- Returns
- A beautiful formatted name that can be used in plots
Definition at line 39 of file styleManager.h.
std::string prettifyName(const std::string &origName, const std::string &nameType) const
◆ prettifySampleName()
std::string MaCh3Plotting::StyleManager::prettifySampleName |
( |
const std::string & |
origName | ) |
const |
|
inline |
Convert hideous and vulgar internal sample name into a beautiful presentable name.
The pretty sample names should be specified in the style config file
- Parameters
-
origName | The "internal" name used to uniquely identify the sample inside the plotting code |
- Returns
- A beautiful formatted name that can be used in plots
Definition at line 48 of file styleManager.h.
◆ setPalette() [1/2]
void MaCh3Plotting::StyleManager::setPalette |
( |
const int |
rootPlotStyle | ) |
const |
◆ setPalette() [2/2]
void MaCh3Plotting::StyleManager::setPalette |
( |
const std::string & |
configStyleName | ) |
const |
Set the root colour palette to one of the ones defined in the style config.
- Parameters
-
rootPlotStyle | The name of the palette you want to use, should be the same as it appears in the style config |
Definition at line 20 of file styleManager.cpp.
27 styleDef = palettes[configStyleName];
30 auto paletteDef = GetFromManager<std::vector<std::vector<double>>>(
31 styleDef[
"MarkerColor"],
32 std::vector<std::vector<double>>{
34 {0.0 , 0.33 , 0.66 , 1.0},
35 {0.0 , 0.0 , 0.0 , 0.0},
36 {0.0 , 0.0 , 1.0 , 0.0},
37 {0.0 , 1.0 , 0.0 , 0.0}
38 }, __FILE__, __LINE__);
39 const Int_t NCont = Int_t(paletteDef[0][0]);
41 std::vector<double> stopVec = paletteDef[1];
42 std::vector<double> redsVec = paletteDef[2];
43 std::vector<double> greensVec = paletteDef[3];
44 std::vector<double> bluesVec = paletteDef[4];
47 const size_t NRGBs = stopVec.size();
48 if (redsVec.size() != NRGBs || greensVec.size() != NRGBs ||
49 bluesVec.size() != NRGBs)
51 MACH3LOG_ERROR(
"invalid colour palette defined in style config file: {}");
52 MACH3LOG_ERROR(
"RGB arrays don't all have the same size, please fix that");
56 TColor::CreateGradientColorTable(
int(NRGBs), stopVec.data(), redsVec.data(), greensVec.data(), bluesVec.data(), NCont);
57 gStyle->SetNumberContours(NCont);
◆ setTH1Style()
void MaCh3Plotting::StyleManager::setTH1Style |
( |
TH1 * |
hist, |
|
|
const std::string & |
styleName |
|
) |
| const |
Set the style of a TH1 to one of the styles defined in the style config.
- Parameters
-
hist | The TH1 that you wish to modify |
styleName | The name of the style you want to use, as it appears in the config file |
Definition at line 60 of file styleManager.cpp.
65 styleDef = TH1Styles[styleName];
68 hist->SetMarkerColor(GetFromManager<Color_t>(styleDef[
"MarkerColor"], kRed, __FILE__, __LINE__));
69 hist->SetMarkerStyle(GetFromManager<Color_t>(styleDef[
"MarkerStyle"], 7, __FILE__, __LINE__));
70 hist->SetFillColor(GetFromManager<Color_t>(styleDef[
"FillColor"], kRed, __FILE__, __LINE__));
71 hist->SetFillStyle(GetFromManager<Color_t>(styleDef[
"FillStyle"], 3003, __FILE__, __LINE__));
72 hist->SetLineColor(GetFromManager<Color_t>(styleDef[
"LineColor"], kRed, __FILE__, __LINE__));
73 hist->SetLineStyle(GetFromManager<Color_t>(styleDef[
"LineStyle"], 1, __FILE__, __LINE__));
◆ _styleConfig
YAML::Node MaCh3Plotting::StyleManager::_styleConfig |
|
private |
The documentation for this class was generated from the following files: