I submitted the bug report shown below and got the response shown. But are there any plans to fix the design and/or coding flaws that cause the scripts such as the ones I submitted to not work as a user would reasonably expect them to?
Posted by: Olivier Couet
Related to: [ROOT bugs #98782] Problems with titles and axis minimum and
maximum in TGraph
URL: http://savannah.cern.ch/bugs/?98782
Follow-up Comment:
do:
c1->DrawFrame(0,2,2.2,11)->GetXaxis()->SetTitle(“layer No”);;
Status: None -> Clarified
Open/Closed: Open -> Closed
Submitted by:
Originator Email: billh@hep.upenn.edu
Bug / Feature: Bug report
Category: Graphics 2D/3D
Priority: 5 - Normal
Severity: 3 - Normal
Status: Clarified
Privacy: Public
Assigned to: couet
Open/Closed: Closed
Release: 5.32/00
Discussion Lock:
Operating System: GNU/Linux
-----Original Message-----
I would like to be able to draw multiple graphs on the same Pad with titles
and axis limits of my own choosing. In researching this, I have encountered
numerous difficulties. I am running ROOT 5.32/00. These look like bugs to me
but perhaps I am doing something wrong?
On the roottalk message board
(root.cern.ch/root/roottalk/roottalk03/5140.html) the following script
is shown as an example of how one can add a title to the x-axis of a TGraph,
with the axis limits set by drawing a frame first. But when I run it, the
title does not appear on the graph.
{
c1 = new TCanvas(“c1”,“A Simple Graph Example”,200,10,700,500);
c1->DrawFrame(0,2,2.2,11);
const Int_t n = 20;
Double_t x[n], y[n];
for (Int_t i=0;i<n;i++) {
x[i] = i0.1+0.05;
y[i] = 10sin(x[i]+0.2);
}
gr = new TGraph(n,x,y);
gr->SetMarkerStyle(21);
gr->Draw(“P”);
c1->Update();
gr->GetHistogram()->GetXaxis()->SetTitle(“layer No”);
c1->Modified();
}
I have tried using a TMultiGraph without creating a frame explicitly, and
then setting the x and y titles and axis limits. With this approach, the
titles do appear on the canvas and the x-axis limits are adjusted, but the
y-axis limits specified are ignored. (One must also to be sure not to
attempt to adjust the axes before the graph has been drawn. In that case the
histogram associated with the graph has not been created and the
mg->SetXaxis() function call causes the program to crash.)
{
const Int_t n = 20;
Double_t x[n], y[n];
for (Int_t i=0;i<n;i++) {
x[i] = i0.1+0.05;
y[i] = 10sin(x[i]+0.2);
}
TGraph* gr = new TGraph(n,x,y);
TMultiGraph* mg = new TMultiGraph();
mg->SetTitle(“title;xaxis title; yaxis title”);
mg->Add(gr,"");
TCanvas c1 = new TCanvas();
mg->Draw(“a”);
mg->GetXaxis()->SetLimits(0.,3.);
mg->GetYaxis()->SetLimits(1.,12.);
c1->Modified();
c1->Update();
}
If with the TMultiGraph one instead attempts to draw a frame with the desired
limits before drawing the multigraph, the axis titles appear, but two sets of
superimposed numeric labels are drawn and the limits given in the DrawFrame
command are ignored in plotting the graph.
{
const Int_t n = 20;
Double_t x[n], y[n];
for (Int_t i=0;i<n;i++) {
x[i] = i0.1+0.05;
y[i] = 10sin(x[i]+0.2);
}
TGraph* gr = new TGraph(n,x,y);
TMultiGraph* mg = new TMultiGraph();
mg->SetTitle(“title;xaxis title; yaxis title”);
mg->Add(gr,"");
TCanvas c1 = new TCanvas();
c1->DrawFrame(0.,1.,3.,12.);
mg->Draw(“a”);
}