Canvas Partition does not allow SetTitle()

I followed the canvas2.c example where I splitted the canvas in 3 parts along the x-axis. I would like to have a title above every coordinate system describing its content but equipping the multigraph with the title via SetTitle() does not work. How do I get three titles?

ants_stoch.root (599.4 KB)
ANTSAll.c (8.2 KB)
ants_ref.root (338.2 KB)
ants_ideal.root (291.6 KB)

ROOT Version: 6.14
Platform: Ubuntu 16.04
Compiler: Not Provided


    TFile *inputfile1 = TFile::Open("ants_ref.root");    
    TMultiGraph *mg1; inputfile1->GetObject("mg", mg1);
    mg1->GetHistogram()->SetTitle("Reference Case;;Loss fraction");

    TFile *inputfile2 = TFile::Open("ants_stoch.root");    
    TMultiGraph *mg2; inputfile2->GetObject("mg", mg2);
    TLegend *legend; inputfile2->GetObject("legend", legend);

    TFile *inputfile3 = TFile::Open("ants_ideal.root");    
    TMultiGraph *mg3; inputfile3->GetObject("mg", mg3);
    mg3->GetHistogram()->SetTitle("Something Else;t/s");

It is a known bug that sometimes you cannot simply use “SetTitle” for graphs which were retrieved from a ROOT file. You need to go through its internal “fHistogram”, if you were careless enough to allow it to be created before you saved the graph to a ROOT file. The same will happen if you draw the graph and then try to change its title.

okay you are right now I have the titles now which I would have too if I would have set them before exporting the graphs into the .root file.
But I thought setting the titles after splitting the canvas prevents me from the following problem:

The three titles are there but:

  1. inside the picture
  2. with different size and different horizontal position

How can I change that? I tried playing a little bit with gStyle->setTitleY(); and now I have all of them outside the picture on top of the coordinate system but to change the size and position I have to address them separately. Is that possible?

Maybe @couet knows some simple tricks.

Yes I’ll have a look

@couet Maybe you could add “SetHistogram” to “TMultiGraph” (this would then allow to execute delete mg->GetHistogram(); mg->SetHistogram(0); which works for ordinary graphs).

Yes may be. I’ll comme first with an answer to @Marsupilami question. (asap)

ANTSAll.c (8.5 KB)

1 Like

Thank you very much for the help. To insert a Latex Label is quite a smart Idea :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.