Hi Mike, Try this: { TCanvas *c1 = new TCanvas("c1","test"); TFile f("hsimple.root"); gStyle->SetPalette(1,0); hpxpy->Draw("colz"); c1->Update(); TPaletteAxis *palette = (TPaletteAxis*)hpxpy->GetListOfFunctions()->FindObject("palette"); palette->SetX1NDC(0.1); palette->SetX2NDC(0.12); palette->SetY1NDC(0.1); palette->SetY2NDC(0.5); c1->Modified(); } To change the palette position you should use the "NDC" functions because TPaletteAxis is a TPave and the TPave constructor says: // Because TPave objects (and objects deriving from TPave) have their // master coordinate system in NDC, one cannot use the TBox functions // SetX1,SetY1,SetX2,SetY2 to change the corner coordinates. One should use // instead SetX1NDC, SetY1NDC, SetX2NDC, SetY2NDC. Cheers, Olivier On Sun, 18 Apr 2004, Mike Kordosky wrote: > Hi, > > I use root 4.00/03 built on a linux pc by gcc3.2. > > I'm trying to resize the TPaletteAxis object drawn in conjunction with the > "colz" option for a 2d histogram. Here is a code snippet: > > // p3a is a TPad*, h_e1_gain is a TH2* > p3a->cd(); > h_e1_gain->Draw("colz"); > p3a->Modified(); > p3a->Update(); > TPaletteAxis* palette = > static_cast<TPaletteAxis*>(h_e1_gain->GetListOfFunctions() > ->FindObject("palette")); > cout<<palette->GetX1()<<endl; > cout<<palette->GetX2()<<endl; > palette->SetX2(palette->GetX2()-(palette->GetX2()-palette->GetX1())*0.8); > cout<<palette->GetX1()<<endl; > cout<<palette->GetX2()<<endl; > p3a->Modified(); > p3a->Update(); > > This is done in an executable that uses TRint like this: > int main(){ > TRint app("run_by_run", &argc, argv); > /* > (plotting code) > */ > app.Run(); > } > > > The output is: > > > CINT/ROOT C/C++ Interpreter version 5.15.128, Mar 16 2004 > Type ? for help. Commands must be C++ statements. > Enclose multiple statements between { }. > 59.8333 > 62.8333 > 59.8333 > 60.4333 > > So, the value of fX2 appears to change but the size of the color palette > on the screen does not. My experience is that calling TPad::Modified() > and TPad::Update() tends to solve similar problems but these calls, for > whatever reason, don't work in my case. Furthermore, if I use the mouse to > call Dump() on the palette, I get: > > fName ->907b860 Pave name > fName.*fData TPave > *fTip ->0 !tool tip associated with box > fX1 59.8333 X of 1st point > fY1 -0.5 Y of 1st point > fX2 62.8333 X of 2nd point > fY2 23.5 Y of 2nd point > > Note, that the value of fX2 doesn't agree with the output above. Also, I > notice that when I replace "static_cast" with "dynamic_cast" in the > snippet above, I get a compiler error: > > /home/kordosky/minos/other_code/calib/run_by_run.cc:149: undefined > reference to `typeinfo for TPaletteAxis' > > I don't understand this message. > > So, what must I do to resize a TPaletteAxis? > > Regards, > > Mike Kordosky > > -- Org: CERN - European Laboratory for Particle Physics. Mail: 1211 Geneve 23 - Switzerland Mailbox: J25910 E-Mail: Olivier.Couet@cern.ch Phone: +41 22 7676522 WWW: http://cern.ch/Olivier.Couet/ Fax: +41 22 7677155
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET