ROHLFS Reiner wrote: > > Hi, > > I want to draw a graph on a pad but define the area the graph uses on the pad > by myself. I found the function TPad::RangeAxis(). But the graph looks always > the same independent of the parameter values of this function or if I don't > call this function at all. > It is the same situation with the function TPad::Range(); > > Here is my test macro: > > { > > gROOT->Reset(); > > // Create a new canvas. > c1 = new TCanvas("c1","canvas",50,10,600,300); > > // create a pad > pad = new TPad("p1", "pad", 0.05, 0.05, 0.95, 0.95); > pad->SetFillColor(3); > pad->SetBorderSize(0); > pad->RangeAxis(0.2, 0.2, 0.5, 0.8); > pad->Range(0.0, 0.0, 40., 40.); > pad->Draw(); > > pad->cd(); > // create a graph > Float_t x[] = {8., 12.5, 14.9, 25.8, 30.2}; > Float_t y[] = {16., 14.3, 20.3, 23.5, 29.9}; > graph = new TGraph(5, x, y); > graph->Draw("AL"); > > } > > If I want to define the Range by pressing the right mouse button on the pad and > selecting Range and defining new values (for example X1 = 12.45) nothing > happens but two new strange lines appear on the pad. > > Is it the wrong function I call or do I miss something? The problem with your macro above is that you call graph->Draw with the option "A". This option indicates that you want to automatically compute the range from the graph values. Root will leave about 10 per cent margin on the x and y axis. If you want to have (if I understand correctly!) axis range not connected to the graph range, you should graph->Draw("L") create two TGAxis objects to paint the axis where you want and with your specified values. In version 1.03, I introduced a new function TPad::DrawFrame to force an empty frame with the x and y axis drawn. Here is a modified version of your macro taking advantage of this new function: { gROOT->Reset(); // Create a new canvas. c1 = new TCanvas("c1","canvas",50,10,600,300); // create a pad pad = new TPad("p1", "pad", 0.05, 0.05, 0.95, 0.95); pad->Draw(); pad->cd(); // create a graph Float_t x[] = {8., 12.5, 14.9, 25.8, 30.2}; Float_t y[] = {16., 14.3, 20.3, 23.5, 29.9}; pad->DrawFrame(0., 10, 40, 35); graph = new TGraph(5, x, y); graph->Draw("L"); } Rene Brun
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:21 MET