I’m trying to add a second y-axis but I don’t get it. The documentation
xmin : X origin coordinate in user's coordinates space. xmax : X end axis coordinate in user's coordinates space. ymin : Y origin coordinate in user's coordinates space. ymax : Y end axis coordinate in user's coordinates space. wmin : Lowest value for the tick mark labels written on the axis. wmax : Highest value for the tick mark labels written on the axis. ndiv : Number of divisions. ndiv=N1 + 100*N2 + 10000*N3 N1=number of 1st divisions. N2=number of 2nd divisions. N3=number of 3rd divisions. e.g.: ndiv=0 –> no tick marks. ndiv=2 –> 2 divisions, one tick mark in the middle of the axis. chopt : Drawing options (see below). gridlength: grid length on main tick marks.
on ROOT: TGaxis Class Reference makes absolutely no sense to me.
For example, at the moment I have:
TGaxis *axis = new TGaxis(23, 5, // xmin // xmax
23, 2, // ymin // ymax
4, 2, // wmin // wmax
10,"-", 10); // ndiv // chop // gridlength
resulting in
This makes no sense at all ![]()
complete code:
#include <TFile.h>
#include <TH1.h>
#include "TGaxis.h"
int intensity_vs_depth()
{
const int points=11;
double depth[points]={12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22};
double Energy[points]={1980, 2141, 2209, 2276, 2504, 2537, 2700, 2858, 2925, 3097, 3258};
double Energy_MEV[points]={2.2047, 2.408365, 2.494385, 2.57914, 2.86756, 2.909305, 3.1155, 3.31537, 3.400125, 3.617705, 3.82137 };
double Energy2[points]={615.2, 666.66, 691.66, 716.66, 794.44, 805.55, 863.88, 921.11, 944.44, 1002.77, 1061.38};
double depth_err[points]={0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
double Energy_err[points]={288.0, 361.0, 291.4, 285.67, 302.4, 299.0, 310.35, 319.5, 319.65, 332.0, 343.3};
double Energy_MEV_err[points]={0.06432, 0.156665, 0.068621, 0.06137255, 0.082536, 0.078235, 0.09259275, 0.1041675, 0.10435725, 0.11998, 0.133895};
TCanvas* c=new TCanvas("Energy", "Energy", 1700, 1000);
gROOT->SetStyle("Plain");
gStyle->SetOptStat(0);
// gStyle->SetOptFit(1);
gStyle->SetOptFit(11);
gStyle->SetPadGridX(kTRUE);
gStyle->SetPadGridY(kTRUE);
TGraphErrors *graph = new TGraphErrors(points, depth, Energy_MEV, depth_err, Energy_MEV_err);
graph->GetXaxis()->SetTitle("Depth / mm");
graph->GetYaxis()->SetTitle("Energy / MeV");
graph->SetMarkerSize(3);
graph->SetMarkerColor(kBlue);
graph->SetMarkerStyle(33);
graph->SetTitle("Energy against depth");
TF1 *fit = new TF1("fit","([0]*x + [1])", 11, 23);
fit->SetLineColor(kRed);
fit->SetLineStyle(2);
graph->Fit(fit);
graph->Draw("APL");
fit->Draw("SAME");
// TGaxis *axis = new TGaxis(23, 23, 23, 1, 23, 1, 50,"+");
// TGaxis *axis = new TGaxis(23, 5, 23, 1, 23, 1, 50,"+");
// TGaxis *axis = new TGaxis(23, 5, 23, 1, 5, 1, 50,"+");
TGaxis *axis = new TGaxis(23, 5, // xmin // xmax
23, 2, // ymin // ymax
4, 2, // wmin // wmax
10,"-", 10); // ndiv // chop // gridlength
axis->SetName("axis");
//axis->GetYaxis()->SetTitle("Energy w/o filters / MeV");
axis->Draw();
return 0;
}

