Redraw canvas background around frame

Hi everyone,

I wrote a script that draws a bunch of TBoxes (three of them for each bin), here’s the output:


I’m looking for a way to avoid boxes being plotted outside the plot frame. I know that I can call TPad::RedrawAxis for axes , but how do I also re-draw the labels and the canvas (white) background?

Thanks in advance.

Can you provide a small macro reproducing what you are doing ?
My fist thought will simply be: Do not draw the boxes if they are outside the frame

void macro() {
    auto h = new TH1D("h", "h", 10, 0, 2);
    h->FillRandom("gaus", 10);
    auto b = new TBox(1, -2, 3, 1);


Do not draw the boxes if they are outside the frame

This I already do, but there are boxes that partially overlap with the plot frame that I would like to “truncate” to the frame boundaries. I guess I could just detect the frame boundaries from code and eventually adapt the size of the boxes [1], but first I wanted to ask if there’s a way to redraw some white background on the top.

[1] But then the boxes will stay truncated if I expand the axis ranges…

try the attached macro.
macro.C (613 Bytes)

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