How set static X-Axis in a simple animation?

Hello rooters, I’ve performed an animation of a parabola with TGraph, but I 've not been able to set an static X-Axis. If you look at the .gif file you’ll understand me better.
Thanks in advance.

[code] TCanvas c( " ", " ", 500, 500 );
c.cd();
TGraph g(1 );
g.SetMarkerStyle(10);
g.SetMarkerSize(1.5);
g.SetMarkerColor(1);
g.SetMaximum(400);
g.SetMinimum(0);

for (int i = 0; i < 20; i++) {
g.SetPoint( i , i , i*i+20);
g.Draw( “APC” );
c.Print( “parabola.gif+25” );
}[/code]

After “g.SetPoint(…);” add:
g.GetXaxis()->SetLimits(0, 20);

[quote]After “g.SetPoint(…);” add:
g.GetXaxis()->SetLimits(0, 20);[/quote]

It works perfectly, however, now I’ve tried circular motion and a similar inconvenient appears, but this time with the Y-Axis, here the code and the attachments:

[code] TCanvas c( " ", " ", 500, 500 );
c.cd();
TGraph g(1 );
g.SetMarkerStyle(10);
g.SetMarkerSize(4.5);
g.SetMarkerColor(1);
g.SetMaximum(20);
g.SetMinimum(-20);

for (double i = 0; i < 4TMath::Pi(); i+=0.1) {
g.SetPoint( 0 , 15
TMath::Cos(i) , 15*TMath::Sin(i) );
g.GetXaxis()->SetLimits(-20, 20);
g.Draw( “APC” );
c.Print( “circular.gif+1” );
}
[/code]

After “g.SetPoint(…);” add:
g.GetYaxis()->SetRangeUser(-20, 20);

Thank you. It works.

Hi again, Now I’m trying to perform 3D animation. This time I get errors about coordinates, but I dont understand why and I’ve tried to fix it, but I haven’t been able.

Errors:

[Error in <TCanvas::Range>: illegal world coordinates range: x1=-0.012500, y1=0.000000, x2=0.012500, y2=0.000000 Error in <TCanvas::RangeAxis>: illegal axis coordinates range: xmin=-0.010000, ymin=0.000000, xmax=0.010000, ymax=0.000000 Error in <TView3D::ResetView>: Error in min-max scope Error in <TView3D::ResetView>: Error in min-max scope Error in <TView3D::ResetView>: Error in min-max scope Error in <TView3D::SetRange>: problem setting view Error in <TView3D::ResetView>: Error in min-max scope Error in <TCanvas::Range>: illegal world coordinates range: x1=0.000000, y1=0.000000, x2=-0.000000, y2=-0.000000 Error in <TCanvas::RangeAxis>: illegal axis coordinates range: xmin=0.000000, ymin=0.000000, xmax=-0.000000, ymax=-0.000000

Code:

[code]#include “TCanvas.h”
#include “TMath.h”
#include “TAxis.h”
#include “TGaxis.h”
#include “TGraph.h”
#include “TLegend.h”
#include “TMarker.h”
#include “TH1.h”
#include “TStyle.h”
#include “TLatex.h”
#include “TGraph2D.h”
#include “TFormula.h”
#include “TF1.h”
#include “TVector.h”
#include “TView3D.h”

using namespace std;
int main(int argc, char** argv){
TGraph2D W(1);
W.SetTitle(“Ball Trajectory”);
W.GetZaxis()->SetTitle(“Z”);
W.GetZaxis()->CenterTitle();
W.GetYaxis()->SetTitle(“Y”);
W.GetYaxis()->CenterTitle();
W.GetXaxis()->SetTitle(" X ");
W.GetXaxis()->CenterTitle();
W.SetMarkerStyle(10);
W.SetMarkerSize(1.5);
W.SetMarkerColor(2);

TCanvas c("","",500,500);
c.cd();

for (int i= 0; i < 10 ; i++) {
W.SetPoint( i , i , i*i , 10 );
// W.GetZaxis()->SetRangeUser(-20, 20);
// W.GetYaxis()->SetRangeUser(-20, 20);
//W.GetXaxis()->SetLimits(-20, 20);
W.Draw(“AP”);
c.Print(“3d.gif+5”);
}

return 0;

}[/code]

{
  TGraph2D *W = new TGraph2D(10);

  W->SetMarkerStyle(10);
  W->SetMarkerSize(1.5);
  W->SetMarkerColor(2);

  TCanvas *c = new TCanvas("c","c",500,500);
  TH2F *h2 = new TH2F("h2","Ball Trajectory",10,-20.,20.,10,-20.,20.);
  W->SetHistogram(h2);

   Double_t x,y;
  for (int i= 0; i <  10 ; i++) {
   x = i;
   y = i*i;
   W->SetPoint( i , x  , y, 10. );
   W->Draw("P0");
   gPad->Update();
   c->Print("3d.gif+5");
  }
}