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?
void macro() {
auto h = new TH1D("h", "h", 10, 0, 2);
h->FillRandom("gaus", 10);
auto b = new TBox(1, -2, 3, 1);
b->SetFillColor(kBlue);
h->Draw();
b->Draw();
gPad->RedrawAxis();
}
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…