# How to plot two 2D histograms on the same canvas?

**URL:** <https://root-forum.cern.ch/t/how-to-plot-two-2d-histograms-on-the-same-canvas/53926>\
**Category:** Newbie\
**Tags:** hist, root\
**Created:** [March 8, 2023, 9:46am UTC](https://root-forum.cern.ch/t/how-to-plot-two-2d-histograms-on-the-same-canvas/53926 "2023-03-08T09:46:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Divyang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/7ea924/32.png) [@Divyang](https://root-forum.cern.ch/u/Divyang)\
**Post date:** [March 8, 2023, 9:46am UTC](https://root-forum.cern.ch/t/how-to-plot-two-2d-histograms-on-the-same-canvas/53926/1 "2023-03-08T09:46:28Z")

</div>

Hello everyone,

I saw the attached 2D histogram in one report. As you can notice, there are two 2D histograms on the same canvas, one with colour code and other with red colour. I think this is a nice presentation to notice any difference.

I tried to search but couldn’t find any answer on how to create this kind of a plot. Any suggestions on how to do this would be a great help.

 ![Hist2D](https://root-forum.cern.ch/uploads/default/original/3X/f/6/f6dac2282e16bc6fb23648f467dcbf8296e9dcd2.png)

Thanks,  
Divyang.

---

<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:** [March 8, 2023, 9:54am UTC](https://root-forum.cern.ch/t/how-to-plot-two-2d-histograms-on-the-same-canvas/53926/3 "2023-03-08T09:54:28Z")

</div>

```cpp
h1->SetMarkerColor(kBlue); h1->Draw(); // e.g., () or ("SCAT=0.5")
h2->SetMarkerColor(kRed); h2->Draw("SAME"); // e.g., ("SAME") or ("SAME SCAT=0.5")

```

---

<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:** [March 8, 2023, 9:59am UTC](https://root-forum.cern.ch/t/how-to-plot-two-2d-histograms-on-the-same-canvas/53926/4 "2023-03-08T09:59:03Z")

</div>

[https://root.cern/doc/master/classTHistPainter.html#HP13](https://root.cern/doc/master/classTHistPainter.html#HP13)

---

<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:** [March 8, 2023, 10:50am UTC](https://root-forum.cern.ch/t/how-to-plot-two-2d-histograms-on-the-same-canvas/53926/5 "2023-03-08T10:50:19Z")

</div>

Be careful that le default plotting option for 2D histograms is a “pseudo scatter plot”. I would not recommend it. Instead use the “box” option I pointed. Look at the “same” option used with “box”. It is much better in your case.
