# tutorials/graphics/canvas2.C:: CanvasPartition - adaptation for TRatioPlot

**URL:** <https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824>\
**Category:** ROOT\
**Created:** [February 3, 2020, 10:59am UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824 "2020-02-03T10:59:35Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrian\_sev](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/adrian_sev/32/13169_2.png) [@adrian\_sev](https://root-forum.cern.ch/u/adrian_sev)\
**Post date:** [February 3, 2020, 10:59am UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/1 "2020-02-03T10:59:35Z")

</div>

root 6.18.04  
It seems that the CanvasPartition from the canvas2.C is not working for TRatioPlots (i imagine because the distinct components that a TRatioPlot has). Unfortunately it is not clear to me what pad to reference and how to create a line (Ny=1) of joined TRatioPlots. [here](https://cernbox.cern.ch/index.php/s/SgwDMDBrEHSFAZO) i have my current macro (that does not work as expected) (the CanvasPartition function is copied to the ROOT\_FUNCTIONS.C that i include - at the end of file) (i tried also the version from [here](https://root-forum.cern.ch/t/labels-dropping-off-using-canvaspartition/26097/5))  
Does anybody have a hint about the joining of TRatioPlots? (moreover it seems that i cannot set the range of x axis)  
Thanks a lot!!

---

<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:** [February 3, 2020, 1:23pm UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/2 "2020-02-03T13:23:39Z")

</div>

I have some difficulties to run your example:

```auto
Processing comparison.C...
In file included from input_line_9:1:
In file included from /Users/couet/Downloads/comparison.C:1:
/Users/couet/Downloads/ROOT_FUNCTIONS.C:52:10: fatal error: 'AliEmcalList.h' file not found
#include <AliEmcalList.h>
         ^ ~~~~~~~~~~~~~~~

```

---

<div class="post-metadata">

**Author:** ![adrian\_sev](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/adrian_sev/32/13169_2.png) [@adrian\_sev](https://root-forum.cern.ch/u/adrian_sev)\
**Post date:** [February 3, 2020, 5:39pm UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/3 "2020-02-03T17:39:55Z")

</div>

ermm, sorry, it can be removed, not necessary in the current example.

---

<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:** [February 4, 2020, 8:34am UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/4 "2020-02-04T08:34:51Z")

</div>

Ok, let me know when you have a reproducer i can run.

---

<div class="post-metadata">

**Author:** ![adrian\_sev](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/adrian_sev/32/13169_2.png) [@adrian\_sev](https://root-forum.cern.ch/u/adrian_sev)\
**Post date:** [February 4, 2020, 9:22am UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/5 "2020-02-04T09:22:32Z")

</div>

done, i clear up all non-root usage. thanks a lot for help!

---

<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:** [February 4, 2020, 10:19am UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/6 "2020-02-04T10:19:51Z")

</div>

I downloaded again the files for the cern box you pointed previously and I still get the same error:

```auto
% root comparison.C
   ------------------------------------------------------------------
  | Welcome to ROOT 6.19/01 https://root.cern |
  | (c) 1995-2019, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Jan 27 2020, 12:10:38 |
  | From heads/master@v6-19-01-2559-g811647b31f |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------------

root [0] 
Processing comparison.C...
In file included from input_line_9:1:
In file included from /Users/couet/Downloads/comparison.C:1:
/Users/couet/Downloads/ROOT_FUNCTIONS.C:52:10: fatal error: 'AliEmcalList.h' file not found
#include <AliEmcalList.h>
         ^ ~~~~~~~~~~~~~~~
root [1] 

```

---

<div class="post-metadata">

**Author:** ![adrian\_sev](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/adrian_sev/32/13169_2.png) [@adrian\_sev](https://root-forum.cern.ch/u/adrian_sev)\
**Post date:** [February 4, 2020, 10:25am UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/7 "2020-02-04T10:25:13Z")

</div>

Maybe is a cache thing? i looked again and there is no mention of Ali\* in the file anymore  
Could you please try downloading again?

---

<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:** [February 4, 2020, 10:30am UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/8 "2020-02-04T10:30:30Z")

</div>

Ok it is fine now. Thanks

---

<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:** [February 4, 2020, 11:49am UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/9 "2020-02-04T11:49:54Z")

</div>

I see… You are miss-using CanvasPartition. This function intend to make sure the frames inside the canvas have all the same area taking into account some margin on the left and on the right. You are working at the pads level. A simple TCanvas::Divide() should work.

---

<div class="post-metadata">

**Author:** ![adrian\_sev](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/adrian_sev/32/13169_2.png) [@adrian\_sev](https://root-forum.cern.ch/u/adrian_sev)\
**Post date:** [February 4, 2020, 12:32pm UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/10 "2020-02-04T12:32:05Z")

</div>

I had the impression that the CanvasPartition is to be used to have “joined” figures like in the presented example. How could i replicate what is shown with Divide? i would like to have equal (at least almost) widths of the joined histograms, and only the left most to have visible ticks and labels…  
Thank you!

---

<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:** [February 4, 2020, 12:54pm UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/11 "2020-02-04T12:54:56Z")

</div>

Something like that but with TRatioPlots inside each pad ?

 ![51](https://root-forum.cern.ch/uploads/default/original/3X/8/7/87aa6673d7b52f0fd7186f40bd6836fc0dda0f86.jpeg)

---

<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:** [February 4, 2020, 2:04pm UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/12 "2020-02-04T14:04:55Z")

</div>

Attached is the best thing I got.

[comparison.C](https://root-forum.cern.ch/uploads/short-url/7zmzzbVFlhtDXOREG72SwSOMny8.C) (7.9 KB)

---

<div class="post-metadata">

**Author:** ![adrian\_sev](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/adrian_sev/32/13169_2.png) [@adrian\_sev](https://root-forum.cern.ch/u/adrian_sev)\
**Post date:** [February 4, 2020, 3:43pm UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/13 "2020-02-04T15:43:37Z")

</div>

Thanks a lot! Yes, this is what i wanted (like in your figure above), and your close enough solution is perfect!! Also i see in your plot that for each histo the first 0 is distinct and does not have any clash with what should have been 5 … Could you tell me how did you do it?  
Currently i have the picture below (i tried to set x range to 0, 1.1 but seems to not work)

 ![c8all](https://root-forum.cern.ch/uploads/default/original/3X/f/c/fc56d186399568a1a81eca94a24d81988435170c.png)  
Thanks a lot!!

---

<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:** [February 4, 2020, 3:54pm UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/14 "2020-02-04T15:54:59Z")

</div>

> [@adrian\_sev](#):
>
> Also i see in your plot that for each histo the first 0 is distinct and does not have any clash with what should have been 5

I am not sure what you are talking about. Seems to me the first and last label on the x-axes can be improved with ChangeLabel. I did nothing special

---

<div class="post-metadata">

**Author:** ![adrian\_sev](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/adrian_sev/32/13169_2.png) [@adrian\_sev](https://root-forum.cern.ch/u/adrian_sev)\
**Post date:** [February 18, 2020, 9:44am UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/15 "2020-02-18T09:44:45Z")

</div>

Hi @couet ! On which object did you applied ChangeLabel? Applying on rp-\>GetLowerRefXaxis()-\>ChangeLabel(0,-1,0.) does not work … also, how can i size the x axis unconditionally (no matter the size of the object)? SetRangeUser on both GetLowerRefXaxis() or GetLowerRefGraph()-\>GetXaxis() does not work

---

<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:** [February 18, 2020, 10:18am UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/16 "2020-02-18T10:18:07Z")

</div>

Yes, I see it is hard to access the lower X axis.  
I have no answer for the time being.

---

<div class="post-metadata">

**Author:** ![adrian\_sev](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/adrian_sev/32/13169_2.png) [@adrian\_sev](https://root-forum.cern.ch/u/adrian_sev)\
**Post date:** [February 18, 2020, 10:45am UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/17 "2020-02-18T10:45:15Z")

</div>

just for reference [here](https://cernbox.cern.ch/index.php/s/SgwDMDBrEHSFAZO) is my current code

---

<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:** [March 3, 2020, 10:46am UTC](https://root-forum.cern.ch/t/tutorials-graphics-canvas2-c-canvaspartition-adaptation-for-tratioplot/37824/18 "2020-03-03T10:46:20Z")

</div>

Closed on March 3, 2020, 10:46am UTC

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