Hi:
From the user guide Superimposing Histograms with Different Scales, I know how to superimpose histogram with two scales. But now I need to do that for two TF1 function. I find out that there is no scale member function in TF1, however, I find out that there is GetHistogram to go to TH1. So I write an easy test function:
#include<TCanvas.h>
#include<TF1.h>
#include<TH1.h>
#include<TF2.h>
#include<TAxis.h>
#include<TGaxis.h>
#include<cmath>
int main()
{
TF1 line1("line1",[](auto const*x,auto const*){return std::sin(x[0]);},-5,5);
line1.SetNpx(500);
line1.SetLineColor(kBlack);
line1.SetTitle("strange");
line1.GetXaxis()->SetTitle("x^{y}");
line1.GetYaxis()->SetTitle("y");
line1.GetXaxis()->CenterTitle();
line1.GetYaxis()->CenterTitle();
TCanvas canvas;
line1.Draw("c");
TF1 line2("line2",[](auto const* x,auto const*){return std::pow(x[0],3);},-5,5);
line2.SetNpx(500);
line2.GetHistogram()->Scale(1/line2.GetMaximum());
line2.SetLineColor(kBlue);
line2.SetLineStyle(2);
line2.Draw("csame");
TGaxis rightY(5,-1,5,1,line2.GetMinimum(),line2.GetMaximum(),510,"+L");
rightY.Draw();
canvas.Print("2d.pdf");
}
and then use g++ -std=c++1y -O2 to compile it. But the line2 function does not scale at all2d.pdf (18.3 KB). How I want to ask how to do that correctly?
Thank you very much