Draw middle axis for a function

Dear All,

I have a (hopefully) simple question…

I’m trying to make some drawings using ROOT, which are just supposed to demonstrate the behaviour of “some things”. So I’m not trying to show anything exact, I’m practically just trying to draw a couple of Gaussians on a canvas.

I was wondering if there was a way to draw a vertical axis “in the middle” of the canvas. To have the y axis be drawn there, demonstrating where “0” is on the x axis. (I plan to hide the box around the pad.) Since in this case I’d just want to not show numbers on the axes at all. But I do want to show where 0 is.

I just thought that somebody may know how to do this off the top of their heads, but I’ll keep looking in the meanwhile…

Cheers,
Attila


ROOT Version: 6.18/00
Platform: x86_64-ubuntu1804-gcc7-opt
Compiler: GCC 7.4.0


TGaxis

Something like:

TGaxis *axis = new TGaxis(0.0, gPad->GetUymin(), 0.0, gPad->GetUymax(), 0.0, gPad->GetUymax(), 510, "+L");
axis->SetLineColor(kRed);
axis->SetLabelColor(kRed);
axis->Draw();

Thanks! I’ll give a try to TGaxis as well. As a very first thing I just hid all the “normal” axes, and drew two TArrow-s instead of them. Just to reinforce the simplicity… :stuck_out_tongue:

{
   TCanvas *c1 = new TCanvas("c1", "Test",800,600);
   c1->Range(-1.5,-0.5,1.5,1.5);
   TF1 myfunction("myfunction","x*x",-1.,1.);
   myfunction.Draw("same");
   TGaxis *Xaxis = new TGaxis(-1.,0.,1.,0.,-1.,1.,510," ");
   Xaxis->Draw();
   TGaxis *Yaxis = new TGaxis(0.,-0.2,0.,1.2,-0.2,1.2,510," ");
   Yaxis->Draw();
}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.