# Have a set of point and a colored band in a MultiGraph

**URL:** <https://root-forum.cern.ch/t/have-a-set-of-point-and-a-colored-band-in-a-multigraph/50519>\
**Category:** Newbie\
**Created:** [June 22, 2022, 1:56pm UTC](https://root-forum.cern.ch/t/have-a-set-of-point-and-a-colored-band-in-a-multigraph/50519 "2022-06-22T13:56:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mzriu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e56c9b/32.png) [@mzriu](https://root-forum.cern.ch/u/mzriu)\
**Post date:** [June 22, 2022, 1:56pm UTC](https://root-forum.cern.ch/t/have-a-set-of-point-and-a-colored-band-in-a-multigraph/50519/1 "2022-06-22T13:56:01Z")

</div>

Hi,

I am trying to draw a MultiGraph with a set of data points and their average value/error as a color band. Right now I have the following code :

```auto
TCanvas *c1 = new TCanvas("c1", "Neutron lifetime", 700, 500);
	c1->SetGrid();
	
	TMultiGraph *mg = new TMultiGraph();
	
	TGraphMultiErrors *gme = new TGraphMultiErrors("gme", "Neutron lifetime measurements", e, date_bottle, lifetime_bottle, 0, 0, stat_bottle, stat_bottle);
	gme->AddYError(e, systm_bottle, systp_bottle);
	gme->SetMarkerStyle(20);
	gme->SetMarkerColor(kBlue);
	gme->SetLineColor(kBlue);
	gme->GetXaxis()->SetNdivisions(505);
	gme->GetYaxis()->SetNdivisions(510);
	//gme->Draw("AP; Z");
	//gme->Fit("pol0");
	
	TGraphErrors *bottle_band = new TGraphErrors(2, bottle_x, bottle_y, 0, sig_bottle_y);
	bottle_band->SetFillColor(4);
	bottle_band->SetFillStyle(3010);
	
	mg->Add(gme);
	mg->Add(bottle_band);
	mg->Draw("AP; Z");

```

This code give me this result :  
[test.pdf](https://root-forum.cern.ch/uploads/short-url/jKT0Yq2IWB0HiDvJINIvNhpKM3I.pdf) (13.9 KB)

As you can see my points are showing as intended but the color band does not. When I write :

```auto
mg->Draw("AP; Z; a3");

```

I have the following image :  
[test2.pdf](https://root-forum.cern.ch/uploads/short-url/7vNzxXbMC1fqMZHcGWEV6ttT1KO.pdf) (13.8 KB)

which as you can see is not good at all… How can I solve that in order to have both my points and the color band ?

Best,  
Marius

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [June 22, 2022, 1:59pm UTC](https://root-forum.cern.ch/t/have-a-set-of-point-and-a-colored-band-in-a-multigraph/50519/2 "2022-06-22T13:59:36Z")

</div>

When you `Add` a graph to a multigraph you can specify the drawing option.

---

<div class="post-metadata">

**Author:** ![mzriu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e56c9b/32.png) [@mzriu](https://root-forum.cern.ch/u/mzriu)\
**Post date:** [June 22, 2022, 2:16pm UTC](https://root-forum.cern.ch/t/have-a-set-of-point-and-a-colored-band-in-a-multigraph/50519/3 "2022-06-22T14:16:20Z")

</div>

Thanks for your answer.  
I have changed it to this :

```auto
mg->Add(bottle_band, "a3");
mg->Add(gme, "AP; Z");
mg->Draw();

```

But now the resulting graph is stuck between the y limit of the color band :  
[test3.pdf](https://root-forum.cern.ch/uploads/short-url/xyVuaZglocFFFYXOpcX8J0IduGc.pdf) (13.3 KB)

How can I fix that ?

---

<div class="post-metadata">

**Author:** ![mzriu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e56c9b/32.png) [@mzriu](https://root-forum.cern.ch/u/mzriu)\
**Post date:** [June 22, 2022, 2:35pm UTC](https://root-forum.cern.ch/t/have-a-set-of-point-and-a-colored-band-in-a-multigraph/50519/4 "2022-06-22T14:35:29Z")

</div>

Okay I have it 😅

```auto
mg->Add(bottle_band, "3");
mg->Add(gme, "P; Z");
mg->Draw("A");

```

Thanks !
