Hi all, I am plotting 10 graphs sharing the same x axis on top of each other. Ten plots on top of each other is quite a lot and so my y axis gets a bit crowded. As of now, my y axis shows 0, 0.2, 0.4, 0.6, 0.8 and 1. In order to make my y axis less crowded I would like it to only show 0, 0.5 and 1, but I’m not sure how to do this. Thanks!
#include "TFile.h"
#include "TCanvas.h"
#include "TH1.h"
#include "TGraphAsymmErrors.h"
void mjj_matched_J40 (){
auto f = new TFile ("HaddOutput.root");
std::vector<int> pT2Cut = {90, 100, 110, 120, 130};
int n = pT2Cut.size();
TH1D* h1[n];
TH1D* h2[n];
TH1D* h3[n];
TGraphAsymmErrors *ratio_lead[n];
TGraphAsymmErrors *ratio_sublead[n];
TCanvas *c = new TCanvas("c", "", 500, 1000);
c->Divide(1, 10, 0, 0);
for (int i = 0; i < n; i++) {
f->GetObject(TString::Format("pT2Cut_%d/Total", pT2Cut[i]), h1[i]);
f->GetObject(TString::Format("pT2Cut_%d/Lead", pT2Cut[i]), h2[i]);
f->GetObject(TString::Format("pT2Cut_%d/Sublead", pT2Cut[i]), h3[i]);
c->cd(2*i+1);
ratio_lead[i] = new TGraphAsymmErrors();
ratio_lead[i]->Divide(h2[i], h1[i]);
ratio_lead[i]->Draw("ap");
gPad->SetGridx();
ratio_lead[i]->GetXaxis()->SetLimits(0, 345);
ratio_lead[i]->SetMaximum(1.1);
ratio_lead[i]->SetMinimum(0);
ratio_lead[i]->GetYaxis()->SetTitle("Lead");
ratio_lead[i]->GetXaxis()->SetTitle("m_{JJ} (GeV)");
c->cd(2*i+2);
gPad->SetTickx();
gPad->SetGridx();
ratio_sublead[i] = new TGraphAsymmErrors("f");
ratio_sublead[i]->Divide(h3[i], h1[i]);
ratio_sublead[i]->Draw("ap");
ratio_sublead[i]->GetXaxis()->SetLimits(0, 345);
ratio_sublead[i]->SetMaximum(1.1);
ratio_sublead[i]->SetMinimum(0);
ratio_sublead[i]->GetYaxis()->SetTitle("Sublead");
ratio_sublead[i]->GetXaxis()->SetTitle("m_{JJ} (GeV)");
}
c->cd(0);
}