# Three View Classes Can't work in a same Canvas

**URL:** <https://root-forum.cern.ch/t/three-view-classes-cant-work-in-a-same-canvas/50878>\
**Category:** Garfield++\
**Created:** [July 20, 2022, 2:38pm UTC](https://root-forum.cern.ch/t/three-view-classes-cant-work-in-a-same-canvas/50878 "2022-07-20T14:38:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [July 20, 2022, 2:38pm UTC](https://root-forum.cern.ch/t/three-view-classes-cant-work-in-a-same-canvas/50878/1 "2022-07-20T14:38:01Z")

</div>

Dear Experts

It seems that whenever I try to draw `ViewCell`, `ViewDrift`, `ViewField` to a same TCanvas there will only be two of them. It works fine if I try any combinations of two of them. I tried the Example `wire2d` in Elmer and only get the view of geometry and drift line, also in my own code the same thing happens.  
Any clues…?

---

<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:** [July 20, 2022, 2:55pm UTC](https://root-forum.cern.ch/t/three-view-classes-cant-work-in-a-same-canvas/50878/2 "2022-07-20T14:55:43Z")

</div>

I think @hschindl can help.

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [July 21, 2022, 4:06pm UTC](https://root-forum.cern.ch/t/three-view-classes-cant-work-in-a-same-canvas/50878/3 "2022-07-21T16:06:19Z")

</div>

Hi,  
for the `wire2d` example it works for me with the attached slightly modified version of the program.

[wire2d.cc](https://root-forum.cern.ch/uploads/short-url/4eRApeU3U5pcPABjpiODCcIYxsV.cc) (3.3 KB)

But it may indeed not work out of the box in other situations. If you have another example where it doesn’t work, please post a minimal working version and I’ll take a look…

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [July 21, 2022, 4:26pm UTC](https://root-forum.cern.ch/t/three-view-classes-cant-work-in-a-same-canvas/50878/4 "2022-07-21T16:26:32Z")

</div>

Thank you, here is the one, I believe I made some mistake to cause this problem…  
[xt\_minimal.zip](https://root-forum.cern.ch/uploads/short-url/xlbsUkLWToBfICX167bnSkaApsD.zip) (25.9 KB)

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [July 23, 2022, 8:56am UTC](https://root-forum.cern.ch/t/three-view-classes-cant-work-in-a-same-canvas/50878/5 "2022-07-23T08:56:52Z")

</div>

By default, each `View...` object uses its own canvas. You need to set the canvas to be painted on explicitly (using the method `SetCanvas`) if you want to combine multiple plots on the same canvas.

---

<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:** [August 6, 2022, 8:57am UTC](https://root-forum.cern.ch/t/three-view-classes-cant-work-in-a-same-canvas/50878/6 "2022-08-06T08:57:49Z")

</div>

Closed on August 6, 2022, 8:57am UTC

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