Hi Brett,
Do:
void gtest1 (void)
{
graph = new TGraph();
int i;
for (i=0; i<10; ++i) {
graph->SetPoint(i,i+0.5,i+0.5);
}
graph->Draw("A*");
ax = graph->GetXaxis();
ay = graph->GetYaxis();
ax->SetRangeUser(2.0,4.0);
graph->SetMinimum(2);
graph->SetMaximum(4);
c1->Modified();
}
or better
void gtest2 (void)
{
graph = new TGraph();
int i;
for (i=0; i<10; ++i) {
graph->SetPoint(i,i+0.5,i+0.5);
}
TCanvas *c1 = new TCanvas();
c1->DrawFrame(2,2,4,4);
graph->Draw("*");
}
Rene Brun
On Mon, 9 Sep 2002, Brett Viren wrote:
> Hi,
>
> I want to have control over the range of X and Y axis in a TGraph, but
> attempts to change the Y range go ignored. As an example:
>
>
> // graph_test.C
> TCanvas* canvas=0;
> TGraph* graph = 0;
> TAxis *ax=0, *ay=0;
> void graph_test (void)
> {
> graph = new TGraph();
> int i;
> for (i=0; i<10; ++i) {
> graph->SetPoint(i,i+0.5,i+0.5);
> }
> graph->Draw("A*");
> ax = graph->GetXaxis();
> ay = graph->GetYaxis();
> ax->SetRangeUser(2.0,4.0);
> ay->SetRangeUser(2.0,4.0);
> c1->Modified();
> }
> // end graph_test.C
>
>
> Running this, only the X range is modified. Is this a bug or a
> feature?
>
> If the latter, how can I modify the Y range (that is, from code not
> interactively).
>
> Thanks,
> -Brett.
>
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:09 MET