# Creating a log and linear plot in the same canvas pad using THStack

**URL:** <https://root-forum.cern.ch/t/creating-a-log-and-linear-plot-in-the-same-canvas-pad-using-thstack/55729>\
**Category:** Newbie\
**Created:** [July 18, 2023, 1:46pm UTC](https://root-forum.cern.ch/t/creating-a-log-and-linear-plot-in-the-same-canvas-pad-using-thstack/55729 "2023-07-18T13:46:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xavier\_James](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xavier_james/32/32932_2.png) [@Xavier\_James](https://root-forum.cern.ch/u/Xavier_James)\
**Post date:** [July 18, 2023, 1:46pm UTC](https://root-forum.cern.ch/t/creating-a-log-and-linear-plot-in-the-same-canvas-pad-using-thstack/55729/1 "2023-07-18T13:46:34Z")

</div>

Hi all,

I am currently having trouble with the issue of being able to display a log and a linear plot in the same pad using THStack. I know that one of the pads should be transparent, however, I am having difficulty in making one of the histograms remain in log form. Also, I do not know where the axes went as well.

This has definitely been a learning curve but any help is appreciated. Thank you.

[8.7\_ll\_gate\_bgs.C](https://root-forum.cern.ch/uploads/short-url/6o8GkOcDDngHFS96MwHPq8QnsQY.C) (4.8 KB)

_ROOT Version:_ Not Provided  
_Platform:_ Not Provided  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [July 18, 2023, 2:40pm UTC](https://root-forum.cern.ch/t/creating-a-log-and-linear-plot-in-the-same-canvas-pad-using-thstack/55729/2 "2023-07-18T14:40:44Z")

</div>

Dear @Xavier_James ,  
A similar question has already been replied at [How to plot with a linear and log scale on two different axes on same plot?](https://root-forum.cern.ch/t/how-to-plot-with-a-linear-and-log-scale-on-two-different-axes-on-same-plot/27008) (btw, you are not looking for `THStack` in your case)

Cheers,  
Vincenzo

---

<div class="post-metadata">

**Author:** ![Xavier\_James](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xavier_james/32/32932_2.png) [@Xavier\_James](https://root-forum.cern.ch/u/Xavier_James)\
**Post date:** [July 18, 2023, 2:44pm UTC](https://root-forum.cern.ch/t/creating-a-log-and-linear-plot-in-the-same-canvas-pad-using-thstack/55729/3 "2023-07-18T14:44:13Z")

</div>

Thank you! I will make sure to check there now.

---

<div class="post-metadata">

**Author:** ![Xavier\_James](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xavier_james/32/32932_2.png) [@Xavier\_James](https://root-forum.cern.ch/u/Xavier_James)\
**Post date:** [July 18, 2023, 2:46pm UTC](https://root-forum.cern.ch/t/creating-a-log-and-linear-plot-in-the-same-canvas-pad-using-thstack/55729/4 "2023-07-18T14:46:23Z")

</div>

Previously, I did try to implement from the forum link you had sent. Unfortunately, I am not able to get the similar results.

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [July 18, 2023, 2:50pm UTC](https://root-forum.cern.ch/t/creating-a-log-and-linear-plot-in-the-same-canvas-pad-using-thstack/55729/5 "2023-07-18T14:50:50Z")

</div>

This means you tried `Draw("SAME X+ Y+")` etc.? (and without using `THStack`)

---

<div class="post-metadata">

**Author:** ![Xavier\_James](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xavier_james/32/32932_2.png) [@Xavier\_James](https://root-forum.cern.ch/u/Xavier_James)\
**Post date:** [July 18, 2023, 3:15pm UTC](https://root-forum.cern.ch/t/creating-a-log-and-linear-plot-in-the-same-canvas-pad-using-thstack/55729/6 "2023-07-18T15:15:14Z")

</div>

Yes. And I have tried the same example script without using THStack. Here is what I had attempted in my script similar to the other post. In lines 119-128.

There were some errors for using TPad itself and  
[8.7\_ll\_gate\_bgs.C](https://root-forum.cern.ch/uploads/short-url/1S85DzE9pkGaoK3C8tD1Ob52gF6.C) (5.5 KB)  
C:147:11: error: no member named ‘SetLogy’ in ‘TH1D’  
Blog\_pad-\>SetLogy(1);

```auto

```

---

<div class="post-metadata">

**Author:** ![Xavier\_James](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xavier_james/32/32932_2.png) [@Xavier\_James](https://root-forum.cern.ch/u/Xavier_James)\
**Post date:** [July 18, 2023, 3:16pm UTC](https://root-forum.cern.ch/t/creating-a-log-and-linear-plot-in-the-same-canvas-pad-using-thstack/55729/7 "2023-07-18T15:16:27Z")

</div>

And using gPad on just one of the histograms when plotting together on the canvas does not work. I apologize trying my best to understand.

---

<div class="post-metadata">

**Author:** ![Xavier\_James](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xavier_james/32/32932_2.png) [@Xavier\_James](https://root-forum.cern.ch/u/Xavier_James)\
**Post date:** [July 18, 2023, 3:37pm UTC](https://root-forum.cern.ch/t/creating-a-log-and-linear-plot-in-the-same-canvas-pad-using-thstack/55729/8 "2023-07-18T15:37:26Z")

</div>

From using the updated code.

 ![Screenshot from 2023-07-18 11-36-49](https://root-forum.cern.ch/uploads/default/original/3X/b/6/b60b0171a73197c2e8e768ff270703a40e3aabce.png)  
[8.7\_ll\_gate\_bgs.C](https://root-forum.cern.ch/uploads/short-url/ix8f7V4fjTA8jildtokadD2w5vi.C) (5.4 KB)
