19 #include <TGraphAsymmErrors.h>
21 #include <TMultiGraph.h>
28 namespace experimental {
32 const std::string& xaxis_title,
33 const std::string& yaxis_title,
bool legend, TStyle* style,
34 int width,
int height)
35 : ts_(ts), s_(style) {
40 mg_ =
new TMultiGraph();
41 c_->SetCanvasSize(width, height);
43 mg_->SetTitle(
Concat(title,
";", xaxis_title,
";", yaxis_title).c_str());
60 const std::string& legend_label,
61 const char* add_mg_options,
short line_color,
62 float line_color_alpha,
short line_style,
63 short line_width,
short marker_color,
64 float marker_color_alpha,
short marker_style,
65 float marker_size,
short fill_color,
66 float fill_color_alpha,
short fill_style) {
73 "The time series stored in this line graph does not contain "
75 ts_name,
"). Operation aborted.");
84 gr =
new TGraph(xvals.size(), xvals.data(), yvals.data());
86 gr =
new TGraphAsymmErrors(xvals.size(), xvals.data(), yvals.data(),
87 nullptr,
nullptr, el.data(), eh.data());
89 gr->SetTitle(legend_label.c_str());
90 gr->InvertBit(TGraph::EStatusBits::kNotEditable);
91 gr->SetLineColorAlpha(line_color, line_color_alpha);
92 gr->SetLineStyle(line_style);
93 gr->SetLineWidth(line_width);
94 gr->SetMarkerColorAlpha(marker_color, marker_color_alpha);
95 gr->SetMarkerStyle(marker_style);
96 gr->SetMarkerSize(marker_size);
97 gr->SetFillColorAlpha(fill_color, fill_color_alpha);
98 gr->SetFillStyle(fill_style);
100 mg_->Add(gr, add_mg_options);
101 if (
l_ && legend_label !=
"") {
102 l_->AddEntry(gr, legend_label.c_str());
111 c_->Draw(canvas_draw_option);
124 "LineGraph::SetLegendPos",
125 "This LineGraph was created without legend. Operation aborted.");
139 "LineGraph::SetLegendPosNDC",
140 "This LineGraph was created without legend. Operation aborted.");
146 const std::vector<std::string>& extensions) {
148 for (
auto& ext : extensions) {
149 auto full_path =
Concat(filenpath_wo_extension, ext);
150 Log::Info(
"LineGraph::SaveAs",
"Saved LineGraph at: ", full_path);
151 c_->SaveAs(full_path.c_str());
171 const std::string& ts_name)
const {
174 static std::vector<TGraph*> kEmpty;
static void Info(const std::string &location, const Args &... parts)
Prints information message.
static void Warning(const std::string &location, const Args &... parts)
Prints warning message.
TGraph * Add(const std::string &ts_name, const std::string &legend_name="", const char *add_mg_options="L", short line_color=1, float line_color_alpha=1.0, short line_style=1, short line_width=1, short marker_color=1, float marker_color_alpha=1.0, short marker_style=1, float marker_size=1, short fill_color=0, float fill_color_alpha=1.0, short fill_style=1000)
void SetLegendPosNDC(real_t x1, real_t y1, real_t x2, real_t y2)
LineGraph(const TimeSeries *ts, const std::string &title="", const std::string &xaxis_title="", const std::string &yaxis_title="", bool legend=true, TStyle *style=nullptr, int width=700, int height=500)
TMultiGraph * GetTMultiGraph()
std::unordered_map< std::string, std::vector< TGraph * > > id_tgraphs_map_
const std::vector< TGraph * > & GetTGraphs(const std::string &ts_name) const
void SetMultiGraphDrawOption(const std::string &s)
void SaveAs(const std::string &filenpath_wo_extension, const std::vector< std::string > &extensions)
void SetLegendPos(real_t x1, real_t y1, real_t x2, real_t y2)
std::string mg_draw_option_
void Draw(const char *canvas_draw_option="")
const std::vector< real_t > & GetYValues(const std::string &id) const
const std::vector< real_t > & GetYErrorHigh(const std::string &id) const
bool Contains(const std::string &id) const
Returns whether a times series with given id exists in this object.
const std::vector< real_t > & GetYErrorLow(const std::string &id) const
const std::vector< real_t > & GetXValues(const std::string &id) const
std::string Concat(const Args &... parts)
Concatenates all arguments into a string. Equivalent to streaming all arguments into a stringstream a...