/* c++ -o testaxis `root-config --glibs --cflags` -lm testaxis.cpp */ #include #include "TH1F.h" #include "TCanvas.h" #include "TLegend.h" #include "TGaxis.h" #include "TF1.h" using namespace std ; float func (float x) { return x ; // return cbrt (x) ; } float invfunc (float x) { return x ; // return pow (x,3) ; } Double_t axistransform (Double_t *x, Double_t *par) { // return invfunc (x[0]) ; return x[0] ; } // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- int main (int argc, char ** argv) { TCanvas clims ("clims", "", 600, 600) ; TH1F * dh = new TH1F ("dh", "dh", 10, 0, 1) ; dh->Fill (0.1, 2.) ; dh->Fill (0.9, -2.) ; dh->SetStats (0) ; dh->Draw ("hist") ; TF1 transform ("transform", axistransform, dh->GetMaximum (), dh->GetMaximum (), 0) ; TGaxis newaxis ( dh->GetXaxis ()->GetXmin (), dh->GetMinimum (), dh->GetXaxis ()->GetXmin (), dh->GetMaximum (), "transform", 505, "") ; // 10, // "", // Double_t gridlength) newaxis.SetLineColor (kRed) ; newaxis.SetLabelColor (kRed) ; newaxis.Draw () ; clims.SaveAs ("problem.png") ; return 0 ; }