# Plotting to mother canvas instead of sub-pad

**URL:** <https://root-forum.cern.ch/t/plotting-to-mother-canvas-instead-of-sub-pad/36792>\
**Category:** ROOT\
**Tags:** graphics\
**Created:** [November 12, 2019, 9:34pm UTC](https://root-forum.cern.ch/t/plotting-to-mother-canvas-instead-of-sub-pad/36792 "2019-11-12T21:34:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![glenawarren](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/278dde/32.png) [@glenawarren](https://root-forum.cern.ch/u/glenawarren)\
**Post date:** [November 12, 2019, 9:34pm UTC](https://root-forum.cern.ch/t/plotting-to-mother-canvas-instead-of-sub-pad/36792/1 "2019-11-12T21:34:29Z")

</div>

Can someone explain to me why the following code fails to draw the histogram on the first sub pad (appears to be on the mother canvas) and, naturally, how to get ROOT to draw it on the first sub pad. I feel like I’m missing something really basic here.

```auto
  TH1F* hFrame = new TH1F("hFrame","Ellipse",100, -2, 2);
  hFrame->SetMinimum(-2);
  hFrame->SetMaximum(2);

  TCanvas* c2 = new TCanvas("c2","c2", 900, 400);
  c2->Divide(2,1);

  c2->cd(1);
  hFrame->DrawClone();

```

* * *

_ROOT_ Version: 6.18/04  
_Platform:_ MacOS 10.14.6

* * *

---

<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:** [November 13, 2019, 7:19am UTC](https://root-forum.cern.ch/t/plotting-to-mother-canvas-instead-of-sub-pad/36792/2 "2019-11-13T07:19:20Z")

</div>

Try with: `hFrame->DrawCopy();`

If it doesn’t help, try to play with ([there is a long standing problem with ROOT + Cocoa](https://root-forum.cern.ch/t/canvas-will-not-show/27582/10)):

> [@Canvas not displayed while executing the macro hsum.C on MacOS](https://root-forum.cern.ch/t/canvas-not-displayed-while-executing-the-macro-hsum-c-on-macos/30788/2):
>
> After each c1-\>Update(); add one or two calls: gSystem-\>ProcessEvents();

---

<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:** [November 13, 2019, 8:40am UTC](https://root-forum.cern.ch/t/plotting-to-mother-canvas-instead-of-sub-pad/36792/3 "2019-11-13T08:40:30Z")

</div>

Why don’t you simply use `hFrame->Draw();` ? It works fine.

---

<div class="post-metadata">

**Author:** ![glenawarren](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/278dde/32.png) [@glenawarren](https://root-forum.cern.ch/u/glenawarren)\
**Post date:** [November 14, 2019, 10:34pm UTC](https://root-forum.cern.ch/t/plotting-to-mother-canvas-instead-of-sub-pad/36792/4 "2019-11-14T22:34:02Z")

</div>

DrawCopy works fine. Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [November 28, 2019, 10:34pm UTC](https://root-forum.cern.ch/t/plotting-to-mother-canvas-instead-of-sub-pad/36792/5 "2019-11-28T22:34:05Z")

</div>

Closed on November 28, 2019, 10:34pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
