Shading below a TGraph

I have draw these two graphs. Now want to shade area under curve. How can i do this?

can you post the macro doing this graphs ?

multigraph.C (1.2 KB)

void multigraph()
{
   gStyle->SetOptFit();
   auto c1 = new TCanvas("c1","multigraph",700,500);
   c1->SetGrid();
   auto *mg = new TMultiGraph();

   const Int_t n = 11;
   Double_t x[]  = {0,1997,3219,3901,3297,2800,2233,1656,1121,802,762};
   Double_t x1[] = {9700,8426,7435,6009,3799,3047,2348,1698,1134,805,765};
   Double_t y[]  = {3,3.5,4,5,8,10,13,18,28,38,40};

   auto g2 = new TGraph(n, x1, y);
   g2->SetPoint(n,x1[n-1],y[0]);

   mg->Add(g2);
   g2->SetFillColor(kGreen-2);

   auto g1 = new TGraph(n, x, y);
   //g1->SetFillColor(kRed-2);
   g1->SetPoint(n,x[0],y[n-1]);
   mg->Add(g1);

   mg->SetTitle("; m^{2}_{12};tan#beta");
   mg->GetXaxis()->CenterTitle(true);
   mg->GetYaxis()->CenterTitle(true);
   mg->Draw("ACF");

   c1->RedrawAxis("G");
}

Thanks

When I try to allign the X, Y titles at centre graph X, Y scales change. Is it possible just alling title without changing scale? Graph with left allign is as under;

It sounds like a bug. Can you make a Jira report ?

Yes.Why not? I have submitted

I just copy your macro in file and output is attached. area below shadow is grid lines free

You need option G in RedrawAxis in order to have the grid redrawn

Problem still continues.

Run the attached macro and check the file multigraph.pdf it generates.
multigraph.C (800 Bytes)

Which root version are you using ? on which machine ?

Still getting the same error with this macro. I am using root-6.14/06 on ubuntu 18.04 LTS

You mean no grid ?
can you try a more recent version ?

Trying another version will create problem for me. Because then i have to setup the whole setup of softwares again.

I get the same (no grid under the white area), tried with v6.20.00 and 6.20.04, Ubuntu 18.04 on WSL.

Yes you are right it is fixed in 6.22.

instead of

   c1->RedrawAxis("G");

do

   mg->GetHistogram()->DrawCopy("sameaxig");
1 Like

Oh really it works.Problem fixed.

I got this reply after reporting bug;
The faulty call is mg->GetXaxis(); (not need to do centertitle) …
Does it means we can’t center a title??

I am now debugging the problem in the JIRA ticket. I updated what I found to keep track of my investigations. That’s more for me than for you.