Visualisation of plots: draw option

Dear All,
In my plot I attached here I have signal in black and bkg drawn using colz option, as you can see we don’t have any information about the intensity of the signal, can someone advise please what is the good way to do it ? I was thinking to use both colz and have two Z-axis, but then the colors will mix up and it will be hard to identifier the signal and bkg.


Thanks in advance.
Cheers,
diallo.

You could use a lego plot (though these are usually quite unpopular):


Which you could make using:
plot1.Draw("LEGO") plot2.Draw("LEGO SAME")

You could also change your plot a little by using the “SCAT” option:

plot.Draw(“COLZ”)
plot2.Draw(“SCAT=20 SAME”)

Neither are great though, this is a tough thing to plot.

Hello,
Thank you, I used 2D stack histo and looks good like.


cheers,
diallo

or:

{
   TCanvas *c1 = new TCanvas("c1");

   TH2F *h1 = new TH2F("h1","h1",40,-4,4,40,-4,4);
   TH2F *h2 = new TH2F("h2","h2",40,-4,4,40,-4,4);
   h1->SetBit(TH1::kNoStats);
   h2->SetBit(TH1::kNoStats);
   Double_t a,b;
   for (Int_t i=0;i<5000;i++) {
      gRandom->Rannor(a,b);
      h1->Fill(a-1.5,b-1.5);
      h2->Fill(a+1.5,b+1.5);
   }
   TExec *ex1 = new TExec("ex1","gStyle->SetPalette(kBird);");
   TExec *ex2 = new TExec("ex2","gStyle->SetPalette(kCherry,0,0.5);");
   h1->Draw("col");
   ex1->Draw();
   h1->Draw("colz same");

   TPaletteAxis *palette = new TPaletteAxis(-4.899714,-3.989474,-4.441261,4.010526,h2);
   palette->SetLabelColor(1);
   palette->SetLabelFont(42);
   palette->SetLabelOffset(0.005);
   palette->SetLabelSize(0.035);
   palette->SetTitleOffset(1);
   palette->SetTitleSize(0.035);

   int ci = 1433;
   color = new TColor(ci, 0.9823529, 0.9762255, 0.9764706, " ", 0.5);
   palette->SetFillColor(ci);
   palette->SetFillStyle(1001);
   h2->GetListOfFunctions()->Add(palette,"br");

   ex2->Draw();
   h2->Draw("colz same");

}

Hi Couet,
Thanks, your output is just amazing it’s what I really want I run it by just changing “ci = 1433 to int ci = 1433” and, “color = … by TColor* color = …”

.
So I tried to repoduce this by modifying the code a little bit, but I go something strange, here the code modified for instance:

#include "TROOT.h"    
#include "TObject.h" 
#include "TFile.h"
#include "TTree.h"
#include "TH2.h"
#include "TMath.h"
#include "TGraph.h"
#include "TColor.h"
#include "TCanvas.h"
#include "TLegend.h"
#include <TStyle.h>
#include <iostream>

#include "AtlasStyle.h"

#include "TROOT.h"

void test1 ()
  
{ TCanvas *c1 = new TCanvas("c1");
  TFile* f0 = new TFile("summary_smzz_bkg.root");
  TFile* f2 = new TFile("summary_20_175_signal.root");
  TH2D *hM12_vs_M34_2e2m_smzz= (TH2D*)f0->Get("hM12_vs_M34_2e2m");
  TH2D *hM12_vs_M34_2e2m_20_175  = (TH2D*)f2->Get("hM12_vs_M34_2e2m");

  /* TH2F *h1 = new TH2F("h1","h1",40,-4,4,40,-4,4);
   TH2F *h2 = new TH2F("h2","h2",40,-4,4,40,-4,4);
   h1->SetBit(TH1::kNoStats);
   h2->SetBit(TH1::kNoStats);
     Double_t a,b;
   for (Int_t i=0;i<5000;i++) {
      gRandom->Rannor(a,b);
      h1->Fill(a-1.5,b-1.5);
      h2->Fill(a+1.5,b+1.5);
   }*/
  hM12_vs_M34_2e2m_smzz->SetBit(TH1::kNoStats);
  hM12_vs_M34_2e2m_20_175->SetBit(TH1::kNoStats);
   TExec *ex1 = new TExec("ex1","gStyle->SetPalette(kBird);");
   TExec *ex2 = new TExec("ex2","gStyle->SetPalette(kCherry,0,0.5);");
   hM12_vs_M34_2e2m_smzz->Draw("col");
   ex1->Draw();
   hM12_vs_M34_2e2m_smzz->Draw("colz same");

   TPaletteAxis *palette = new TPaletteAxis(-4.899714,-3.989474,-4.441261,4.010526,hM12_vs_M34_2e2m_20_175);
   palette->SetLabelColor(1);
   palette->SetLabelFont(42);
   palette->SetLabelOffset(0.005);
   palette->SetLabelSize(0.035);
   palette->SetTitleOffset(1);
   palette->SetTitleSize(0.035);

  int  ci = 1433;
  TColor * color = new TColor(ci, 0.9823529, 0.9762255, 0.9764706, " ", 0.5);
   palette->SetFillColor(ci);
   palette->SetFillStyle(1001);
   hM12_vs_M34_2e2m_20_175->GetListOfFunctions()->Add(palette,"br");

   ex2->Draw();
   hM12_vs_M34_2e2m_20_175->Draw("colz same");

}

Could you tell me what’s wrong here please.
Thanks,
diallo

Can I access somewhere your data file in order to run your macro ?

Yeah for sure, I put them in my dropbox, here is the link: https://www.dropbox.com/s/vqmahsa79x9a9jj/files.zip?dl=0
thanks,
cheers,
diallo

I am failing to make it work right now. I have the follwoing macro but there is black lines drawn on top of the plot … I have no idea where they come from from the time being.

void pal2 ()
{
   TCanvas *c1 = new TCanvas("c1","c1",1500,1000);
   c1->SetRightMargin(0.1962751);

   TFile* f0 = new TFile("summary_smzz_bkg.root");
   TFile* f2 = new TFile("summary_20_175_signal.root");
   TH2D *hM12_vs_M34_2e2m_smzz= (TH2D*)f0->Get("hM12_vs_M34_2e2m");
   TH2D *hM12_vs_M34_2e2m_20_175  = (TH2D*)f2->Get("hM12_vs_M34_2e2m");

   hM12_vs_M34_2e2m_smzz->SetBit(TH1::kNoStats);
   hM12_vs_M34_2e2m_20_175->SetBit(TH1::kNoStats);
   TExec *ex1 = new TExec("ex1","gStyle->SetPalette(kBird);");
   TExec *ex2 = new TExec("ex2","gStyle->SetPalette(kCherry,0,0.5);");
   hM12_vs_M34_2e2m_smzz->Draw("col");
   ex1->Draw();
   hM12_vs_M34_2e2m_smzz->Draw("colz same");

   TPaletteAxis *palette = new TPaletteAxis(1150.,0,1200.,1000,hM12_vs_M34_2e2m_20_175);

    hM12_vs_M34_2e2m_20_175->GetListOfFunctions()->Add(palette,"br");

   ex2->Draw();
   hM12_vs_M34_2e2m_20_175->Draw("colz same");

}

Hi Couet,
Don’t I did finally, now it looks good


Here is the script in case someone need this:

TCanvas *c1 = new TCanvas("c1");
   c1->SetLogz();
    c1->SetRightMargin(0.18);
  TFile* f0 = new TFile("summary_smzz_bkg.root");
  TFile* f2 = new TFile("summary_20_175_signal.root");
  TH2D *hM12_vs_M34_2e2m_smzz= (TH2D*)f0->Get("hM12_vs_M34_2e2m");
  TH2D *hM12_vs_M34_2e2m_20_175  = (TH2D*)f2->Get("hM12_vs_M34_2e2m");
   hM12_vs_M34_2e2m_smzz->GetXaxis()->SetRangeUser(0,150);
   hM12_vs_M34_2e2m_smzz->GetYaxis()->SetRangeUser(0,150);
   hM12_vs_M34_2e2m_smzz->GetXaxis()->SetLabelSize(0.035);
   hM12_vs_M34_2e2m_smzz->GetYaxis()->SetLabelSize(0.035);
   hM12_vs_M34_2e2m_smzz->GetZaxis()->SetLabelSize(0.035);
   hM12_vs_M34_2e2m_smzz->SetBit(TH1::kNoStats);
   TExec *ex2 = new TExec("ex2","gStyle->SetPalette(kCherry);");
    hM12_vs_M34_2e2m_smzz->Draw("col");
   ex2->Draw();
   hM12_vs_M34_2e2m_smzz->Draw("colz same");
   TExec *ex1 = new TExec("ex1","gStyle->SetPalette(kBird);");
   TPaletteAxis *palette = new TPaletteAxis(-100,-1,-10,150,hM12_vs_M34_2e2m_20_175);
   palette->SetLabelColor(1);
   palette->SetLabelFont(42);
   palette->SetLabelOffset(0.005);
   palette->SetLabelSize(0.025);
   palette->SetTitleOffset(1);
   palette->SetTitleSize(0.035);
   palette->SetFillStyle(1001);
    hM12_vs_M34_2e2m_20_175->GetZaxis()->SetLabelSize(0);
   hM12_vs_M34_2e2m_20_175->GetListOfFunctions()->Add(palette,"br");
   ex1->Draw();
   hM12_vs_M34_2e2m_20_175->Draw("colz same");

Thanks again for helping.
cheers,
diallo

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.