ROHLFS Reiner wrote: > Hi ROOTers, > > I want to draw a pave and a graph in the same pad. But the pave should be on > top of the graph. > > Here is my test macro: > > { > gROOT->Reset(); > > c1 = new TCanvas("c1","canvas",10,0,350,470); > pad = new TPad("pad", "pad", 0.1, 0.1, 0.9, 0.9); > pad->Draw(); > pad->cd(); > > float x[] = {0., 1.5, 2.}; > float y[] = {0., 0.8, 2.}; > graph = new TGraph(3,x,y); > > pave = new TPaveText(0.5, 0.8, 1.0, 1.0); > pave->AddText("This is a pave"); > > pave->Draw(); > graph->Draw("AL"); > > } > > But now the graph is on top of the pave and you can see only part of the pave. > > If I call first > graph->Draw("AL"); > and than > pave->Draw(); > the pave is on top of the graph. But the coordinates defined in the pave > constructor now are interpreted in the range of the frame of the already drawn > graph. I'm not able to place the pave at the top right corner of the pad > because I'm not allowed to define coordinates > 1.0 in the pave constructor. > Anyhow I think it is a bad idea to define the pave coordinates in the range of > the graph because the graph coordinated may be unknown while the pave is > created. > > Is there a function to put the pave on top of the graph after both are drawn? > > Cheers Reiner. All TPave based classes support an option in the constructor to create the object in the Normalized Device Coordinate (NDC) system (the one of the pad [0,1]). I have modified your macro below to do what you want. Rene Brun { gROOT->Reset(); c1 = new TCanvas("c1","canvas",10,0,350,470); pad = new TPad("pad", "pad", 0.1, 0.1, 0.9, 0.9); pad->Draw(); pad->cd(); float x[] = {0., 1.5, 2.}; float y[] = {0., 0.8, 2.}; graph = new TGraph(3,x,y); pave = new TPaveText(0.5, 0.8, 1.0, 1.0,"brNDC"); pave->AddText("This is a pave"); graph->Draw("AL"); pave->Draw(); }
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:22 MET