dear all,
For the title of y-axis, I can use TPaveText as a trick. And I can shrink the space among plots by setting Margin. But I have no idea how to plot the y-axis labels as that.
Thanks for your help.
Cheers,
Xiaorui Lu
dear all,
For the title of y-axis, I can use TPaveText as a trick. And I can shrink the space among plots by setting Margin. But I have no idea how to plot the y-axis labels as that.
Thanks for your help.
Cheers,
Xiaorui Lu
see example in script below
Rene
{
TCanvas *c1 = new TCanvas("c1","test",600,200);
c1->Divide(3,1,0,0);
c1->cd(1);
gPad->SetLeftMargin(0.15);
gStyle->SetOptTitle(0);
TGraph *g1 = new TGraph(4);
g1->SetTitle(" ");
g1->SetPoint(0,0.3,0.02);
g1->SetPoint(1,0.5,0.04);
g1->SetPoint(2,0.7,0.06);
g1->SetPoint(3,0.9,0.08);
g1->SetMarkerStyle(21);
g1->Draw("ap");
g1->GetYaxis()->SetTitle("X ");
g1->GetYaxis()->SetLabelFont(63);
g1->GetYaxis()->SetLabelSize(12);
g1->GetXaxis()->SetLabelFont(63);
g1->GetXaxis()->SetLabelSize(12);
g1->GetYaxis()->SetTitleOffset(1.2);
g1->GetYaxis()->SetTitleSize(0.07);
c1->cd(2);
TGraph *g2 = (TGraph*)g1->Clone();
g2->Draw("ap");
g2->GetYaxis()->SetTitle("Z ");
g2->GetYaxis()->SetTitleOffset(-0.5);
c1->cd(3);
gPad->SetRightMargin(0.10);
TGraph *g3 = (TGraph*)g1->Clone();
g3->Draw("ap");
g3->GetYaxis()->SetTitle("<M_{#pi#pi}[GeV] ");
g3->GetYaxis()->SetTitleOffset(-1.5);
}
Thanks Rene. Your script gave me some inspiration in producing what I want to plot.
But by using
g2->GetYaxis()->SetTitleOffset(-0.5);
I cannot move the y-axis-title of plot g2 to right side of y-axis.
I attached the produced plot from your script.
Cheers,
Xiaorui
Do you mean"
[quote]I cannot move the y-axis-title of plot g3 to right side of y-axis.
[/quote]or
[quote]I cannot move the y-axis-title of plot g2 to left side of y-axis on the right of pad2
[/quote]Text cannot be drawn outside a pad.
Rene.
Sorry for the confusing words. I wanted to move a y-axis-title into the plot.
For example, in plot g2, we set Y axis title:
g2->GetYaxis()->SetTitle("Z ");
By default the title is put on the left side of the Y-axis in plot g2 and cannot be drawn due to the 0 margin width of the pad. Then I wish the title “Z” could be drawn on the right side of the Y-axis. That is what I was saying “move Y-axis-title to the right side of its axis”.
I had wished “g2->GetYaxis()->SetTitleOffset(-0.5)” could do that. But it did not. Howerver it seems that “g2->GetYaxis()->SetLableOffset(-0.5)” could move label to the other side of the axis.
Wish I am clear this time.
Cheers,
Xiaorui
If you run the code that I posted above, you should get the picture in attachment . It contains what you are requesting.
Rene
Yes. I run your script and also attached the produced plot in my first reply post. I just lost the y-axis-title for plot g2 and g3, as your plot have.
So it is due to my root version? I am using ROOT 4.04/02.
Xiaorui
Yes, move to a more recent version
Rene