Hi Andreas, It is not currently possible to use different color palettes in the same canvas. There are several simple solutions that could be easily implemented. - option to draw in the reverse order of colors (will solve your case). - option to add a color offset in the color palette. In your example, one could create the palette with 18 consecutive colors. For the first plot, just set the palette as now to use the first 9 colors. For the second plot, set the color offset to 10. The color offset could be specified by using the current histogram color, for example. Both options are trivial to implement in the case of contour plots. If enough interest, I will implement them. If somebody has a better idea, let me know. Rene Brun Andreas Zoglauer wrote: > > Hi, > > I have two histograms in my canvas and want to define one color palette > per histogram, e.g. the colors in the first histogram go from black > to white and in the second from white to black. Unfortunately setting the > style via gStyle->SetPalette() changes the palettes in all histograms. > > Is there any function of type H1D->SetStyle(myStyle) which is unharmed > when one sets gStyle-values? > > Here is an example of the problem: > > ////////////////////////////////////////////////////////////////////// > > { > gROOT->Reset(); > > TRandom R; > gRandom->SetSeed(); > const Int_t kUPDATE = 1000; > > c1 = new TCanvas("c1","Canvas",200,200,600,1000); > pad1 = new TPad("pad1","Palette 1",0.05,0.50,0.95,0.95,21); > pad2 = new TPad("pad2","Palette 2",0.05,0.05,0.95,0.45,21); > pad1->Draw(); > pad2->Draw(); > > pad1->cd(); > > Int_t Color[9] = {10, 19, 18, 17, 16, 15, 14, 13, 12}; > gStyle->SetPalette(9, Color); > //pad1->UseCurrentStyle(); > > TH2D* H1 = new TH2D("H1", "Palette 1", 50,-5,5,50,-5,5); > H1->Draw("CONT4"); > > for (Int_t i = 0; i < 10000; i++) { > H1->Fill(gRandom->Gaus(), gRandom->Gaus()); > if (i % kUPDATE == 0) { > pad1->Modified(); > c1->Update(); > } > } > > pad2->cd(); > > Int_t invColor[9] = {12, 13, 14, 15, 16, 17, 18, 19, 10}; > gStyle->SetPalette(9, invColor); > //pad2->UseCurrentStyle(); > > TH2D* H2 = new TH2D("H1", "Palette 1", 50,-5,5,50,-5,5); > H2->Draw("CONT4"); > > for (Int_t i = 0; i < 10000; i++) { > H2->Fill(gRandom->Gaus(), gRandom->Gaus()); > if (i % kUPDATE == 0) { > H2->Draw("CONT4"); > pad2->Modified(); > c1->Update(); > } > } > > // Together: > for (Int_t i = 0; i < 10000; i++) { > H1->Fill(gRandom->Gaus(), gRandom->Gaus()); > H2->Fill(gRandom->Gaus(), gRandom->Gaus()); > if (i % kUPDATE == 0) { > pad1->Modified(); > pad2->Modified(); > c1->Update(); > } > } > > pad1->Modified(); > pad2->Modified(); > c1->Update(); > } > > ////////////////////////////////////////////////////////////////////// > > Any ideas? > > Andreas > > ---------------------------------------------------------------------- > Andreas Zoglauer > > MPI fuer extraterrestrische Physik Phone: +49/89-30000-3848 > Postfach 1312 Fax: +49/89-30000-3569 > 85741 Garching, Germany Email: zog@mpe.mpg.de > ----------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:44 MET