I am trying to make a 2-D histogram of kinetic energy and PROMPT photoelectrons, but trying to set a log scale on the y-axis. The y-axis changes to a log scale but the tick marks dont appear properly and someone told me that it is not centered at 0. I tried “correlation->GetYaxis()->SetRangeUser(1e-1, 5000);” but this did not work. An image of the graph is shown here.
Please fill also the fields below. Note that root -b -q will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug from the ROOT prompt to pre-populate a topic.
auto canvas = new TCanvas("Canvas","Canvas",1400,900);
auto correlation = new TH2F("Kinetic-PromptPE","Kinetic-PromptPE",50,0,250,50,0,5000);
for(size_t i = 0 ;i < promptPE.size(); i++){
if(!kinetic[i].empty()){
correlation->Fill(kinetic[i][kinetic[i].size()-1],promptPE[i]);
}
}
canvas->Draw();
correlation->Draw("COLZ");
gStyle->SetOptStat(0);
gPad->SetLogy(1);
correlation->GetXaxis()->SetTitle("Kinetic Energy / 5 (MeV)");
correlation->GetYaxis()->SetTitle("Prompt PE / 100");
canvas->SaveAs("/exp/sbnd/app/users/ipatel/NC_trigger/plot/Kinetic-PromptPE.png","recreate");
ROOT Version: Not Provided Platform: Not Provided Compiler: Not Provided
I read somewhere that the SetMinimum for TH2F graph makes the z-axis(the color) minimum to 0. Also the other issue that I stated was that the tick-marks on the y-axis dont appear as they normally do for 0,10^2,then`10^3 and so on.
One can use TH1::SetMaximum() and TH1::SetMinimum() to force a particular value for the maximum or the minimum scale on the plot. (For 1-D histograms this means the y-axis, while for 2-D histograms these functions affect the z-axis).
What do mean by that? First of, 0 is impossible to show on a log-scale plot. Second, you have the 10^3 tick shown on your plot: ticks below correspond to 9*10^2, 8*10^2, 7*10^2, …, 2*10^2. The ticks above are for 2*10^3, 3*10^3, and 4*10^3. What exactly is wrong with this?
My advisor just told me that the y-axis is not actually beginning at 0, I understand for a logarithmic scale you cant really have that, but somewhere close should do. Also she said that because the only labeled tickmarks that were showing were the 10^3 and none of the others. So, I was wondering how to actually set the bottom to 0 and get more labeled tickmarks.