Changing axis and label color in a TView

Hello everybody,

I am trying to produce a nice plot of a Lorenz attractor, using TPolyLine3D. The plot itself is pretty easy to produce, but I have a hard time controlling the aspect of the axis, as well as the view angle… Here is the code :

[code]{
gROOT->Reset();

double beta = 4.; double sigma = 10.; double rho = 35.;
double x0 = 1.; double x=x0;
double y0 = 1.; double y=y0;
double z0 = 1.; double z=z0;
double pas = 0.002;

int npoints=10000;
TPolyLine3D *courbe = new TPolyLine3D(npoints);

// create and open a canvas
TCanvas *canvas = new TCanvas( "canvas", "Lorenz", 300, 10, 700, 500 );

// creating view
TView *view = new TView(1);
view->SetRange( -10., -30., -50., 50., 50., 50. );

gStyle->SetAxisColor(1,"xyz");
gStyle->SetLabelColor(1,"xyz");
    gStyle->SetFillColor(0);
gStyle->SetLabelSize(0.03, "xyz");

view->UseCurrentStyle();
view->SetLatitude(77.);
view->SetLongitude(-165.);
view->SetPsi(0.);

for( int i = 0; i < npoints; i++ ) 
{
	// compute next point and add it to the line		
    double x_dot, y_dot, z_dot;
	x_dot = - beta*x + y*z;
	y_dot = sigma*(z-y);
	z_dot = -x*y+rho*y -z;
	
	x = x0 + pas * x_dot; x0 = x;
	y = y0 + pas * y_dot; y0 = y;
	z = z0 + pas * z_dot; z0 = z;

	courbe->SetPoint( i, x, y, z );
}

courbe->SetLineWidth( 1 );
courbe->SetLineColor(1);
courbe->Draw();

view->ShowAxis();
canvas->Update();

}[/code]
I want to have the axis in black. This is why I tried to change the gStyle, but it doesn’t work…
Plus the SetLatitude command has zero effect on the final display… Am I missing something stupid ?

Thank you for your help !!

At the end of your macro, after canvas->Update(), add the three following lines:

   TAxis3D *axis = TAxis3D::GetPadAxis();
   axis->SetLabelColor(kBlack);
   axis->SetAxisColor(kBlack);

Thanks a lot ! :slight_smile: :slight_smile: :slight_smile:

And would you have any idea about why the

view->SetLatitude(77.); view->SetLongitude(-165.); view->SetPsi(0.);
seems to have no effect ? Aren’t the latitude and longitude attributes of the TView ?

And while I’m at it, does anybody have any idea how I can have the cubic 3D frame drawn (not only the 3 axes, but the 12 sides of the cube containing the plot) ?

Anyway, thanks again for this quick and efficient answer !

Try:

   canvas->SetTheta(...);
   canvas->SetPhi(...);

TAxis3D is the guy which paints the 3D axis. In this class nothing but axis are drawn. So the box cannot be automatically drawn by just setting a flag. But in your example you already draw 10000 lines so I guess you can draw a few more to make the box.

Yes indeed… :blush:

Thank you very much !

This is a COOL script. I think it’s worth adding it to the tutorials.
Cheers,
Oliver