ROOT Version:
Platform: Linux
Compiler: Clang 11.0.0 x86_64 / C++
Hello,
I want to plot the legend of the graph I draw to the right of the graph.
If I use
TGraph *g[matrix_of_cell_values.size ()];
TMultiGraph *mg = new TMultiGraph ();
auto mycanvas2 = new TCanvas ();
TLegend *leg = new TLegend (0.8, 0.7, 1.2, 0.9);
leg->SetTextSize (0.05);
leg->SetFillColor (0);
for (int i = 0; i < int (matrix_of_cell_values.size ()); i++)
{
std::cout << matrix_of_cell_values[i].size () << std::endl;
std::cout << matrix_of_cell_values.size () << std::endl;
g[i] = new TGraph (int (matrix_of_cell_values[i].size ()), &matrix_of_time_as_TDatime_as_doubles[i][0],
&matrix_of_cell_values[i][0]);
g[i]->SetMarkerStyle (20);
g[i]->SetMarkerColor (i + 1);
mg->Add (g[i]);
leg->AddEntry (g[i], (Form ("Zelle %d", cell_identifier_vector[i])));
}
mg->Draw ("ap");
leg->Draw ();
mg->SetTitle (Form ("Zelle %d", cell_identifier_vector[0]));
mg->GetXaxis ()->SetTitle ("Zeit in UTC");
mg->GetXaxis ()->CenterTitle ();
mg->GetYaxis ()->SetTitle (cell_attribute.c_str ());
mg->GetYaxis ()->CenterTitle ();
mg->GetXaxis ()->SetTimeDisplay (1);
mg->GetXaxis ()->SetNdivisions (505);
mg->GetXaxis ()->SetTimeFormat ("%H:%M");
mg->GetXaxis ()->SetTimeOffset (0, "gmt");
mycanvas2->SetGrid ();
mycanvas2->Print ("multi_graph.pdf");
It will draw the legend to the right, but cut it roughly in the middle.
I want the legend to extend beyond the actual canvas or the canvas to be extended, so my whole legend fits to the right.
Is there a way to do that?