Drawing rectangle


ROOT Version: 5.34/36
Platform: lxplus
Compiler: Not Provided
___After plotting a 2D histogram, I want to draw a rectangel in the plot to highlight some important information. How would I be able to do that?

Hi,
try to use the TBox class.

Cheers,
Stefano

Hi Stefano,

Thank you for your suggestion. When I use TBox in my graph, it blocks whatever orginally was in there. But I don’t want that. I just want the edge of the box so that whatever orginally was there could remain there. Do you have other suggestions? Thanks.

Cheers,
QC

You can use the option inherited by TAttLine and TAttFill.
Try

box->SetFillAlphaColor(0,0);
box->SetLineColor(kRed);

Look at
TBox::SetFillColorAlpha()
TBox:SetLineColor()

Cheers,
Stefano

Thank you. Unfortunately I’ve tried

Box=ROOT.TBox(-50,100,50,200)
Box.Draw()
Box.SetFillColorAlpha(0,0)
Box.SetLineColor(ROOT.kRed)

and also

Box=ROOT.TBox(-50,100,50,200)
Box.SetFillColorAlpha(0,0)
Box.SetLineColor(ROOT.kRed)
Box.Draw()

but neither of these works. Could you write out explicitly the code I need to draw a transparent box? Thanks.

Cheers,
QC

This should work

box->SetLineColor(kRed);
box->SetFillStyle(0);

Then you can also change the option for the line width

box->SetLineWidth(2);

Moreover, the coordinates of the box should be between 0 and 1, but about this I’m not so sure

Stefano

It works. Thank you!

QC

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