# Drawing errors on a TH2 in the colz style?

**URL:** <https://root-forum.cern.ch/t/drawing-errors-on-a-th2-in-the-colz-style/39231>\
**Category:** Newbie\
**Created:** [May 3, 2020, 5:09pm UTC](https://root-forum.cern.ch/t/drawing-errors-on-a-th2-in-the-colz-style/39231 "2020-05-03T17:09:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eggsAndCoffee](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/ecb155/32.png) [@eggsAndCoffee](https://root-forum.cern.ch/u/eggsAndCoffee)\
**Post date:** [May 3, 2020, 5:09pm UTC](https://root-forum.cern.ch/t/drawing-errors-on-a-th2-in-the-colz-style/39231/1 "2020-05-03T17:09:49Z")

</div>

Hello,

My question seems simple, but I can’t quite find a satisfactory answer. If I have a TH2D _h_ that has been filled, potentially with fractional weights (and certainly with _Sumw2()_ called before filling), how can I draw the Sumw2 errors for each bin in the “colz” style? I would like to do something like the following:

```auto
// TH2D *h has already been declared and filled by here.
TCanvas *c = new TCanvas("c","c",1000,1000);
c->Divide(1,2);

c->cd(1);
h->Draw("colz"); // gives a display of the contents of h

c->cd(2);
h->DrawSumw2Error("colz"); // THIS IS WHAT I WANT TO DO, IS THIS POSSIBLE? 

```

I am aware that _h_ can be drawn with the various E options but this gives a 3D view and is not what I want. I want a 2D colour-coded map of the Sumw2 errors, so that each bin value in the drawn histogram of errors is the square root of the Sumw2 value for that bin in _h_.

I can create a whole new histogram _hErr_ with the same size as _h_ and loop over the bins, using SetBinContent() to assign values of _sqrt( h-\>GetBinError(the\_bin) )_ to the same bin in _hErr_, and then draw _hErr_ with the colz option. But I feel like this functionality might already be provided in the TH2 class and I just can’t find it. Any suggestions?

Thank you.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [May 3, 2020, 7:18pm UTC](https://root-forum.cern.ch/t/drawing-errors-on-a-th2-in-the-colz-style/39231/2 "2020-05-03T19:18:10Z")

</div>

The available drawing options are described in: [THistPainter](https://root.cern/doc/master/classTHistPainter.html)

---

<div class="post-metadata">

**Author:** ![eggsAndCoffee](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/ecb155/32.png) [@eggsAndCoffee](https://root-forum.cern.ch/u/eggsAndCoffee)\
**Post date:** [May 3, 2020, 11:33pm UTC](https://root-forum.cern.ch/t/drawing-errors-on-a-th2-in-the-colz-style/39231/3 "2020-05-03T23:33:49Z")

</div>

Thank you for the reply. Yes I have already seen the options in THistPainter, but all of the various “E” options don’t draw what I’ve described above. Does this mean that a simple 2D histogram of the errors in a TH2 cannot be drawn without first manually filling a new TH2 using GetBinError?

---

<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:** [May 4, 2020, 9:15am UTC](https://root-forum.cern.ch/t/drawing-errors-on-a-th2-in-the-colz-style/39231/4 "2020-05-04T09:15:41Z")

</div>

Yes the option E for 2D histogram produces 3D errors bars. If you want to Draw only the errors as a COL plot like a normal 2D histogram you will need to create a such histogram. The combination of “COL” and “E” options is not implemented.

---

<div class="post-metadata">

**Author:** ![eggsAndCoffee](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/ecb155/32.png) [@eggsAndCoffee](https://root-forum.cern.ch/u/eggsAndCoffee)\
**Post date:** [May 4, 2020, 12:40pm UTC](https://root-forum.cern.ch/t/drawing-errors-on-a-th2-in-the-colz-style/39231/5 "2020-05-04T12:40:35Z")

</div>

Thank you @couet, that makes it clear. This might be an attractive drawing option for future implementation.
