Try (you will need to “convert” it to use histograms instead of graphs):
BTW. Maybe you simply want:
{
TCanvas *c = new TCanvas("c", "c");
c->DrawFrame(-10, 0., 100., 25., "My Title;My X;My Y"); // draw the frame
TF1 *f1 = new TF1("f1", "x", 0., 100.);
f1->Draw("SAME"); // draw the function
r1->Draw("HIST SAME"); // r1 is my first histogram from -10 to 10
r2->Draw("HIST SAME"); // r2 is my second histogram
}