# Labels dropping off using CanvasPartition

**URL:** <https://root-forum.cern.ch/t/labels-dropping-off-using-canvaspartition/26097>\
**Category:** ROOT\
**Created:** [September 4, 2017, 11:56am UTC](https://root-forum.cern.ch/t/labels-dropping-off-using-canvaspartition/26097 "2017-09-04T11:56:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbvh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rbvh/32/13556_2.png) [@rbvh](https://root-forum.cern.ch/u/rbvh)\
**Post date:** [September 4, 2017, 11:56am UTC](https://root-forum.cern.ch/t/labels-dropping-off-using-canvaspartition/26097/1 "2017-09-04T11:56:25Z")

</div>

Dear ROOTers,

I’m having issues using the function CanvasPartition here: [https://root.cern.ch/root/html/tutorials/graphics/canvas2.C.html](https://root.cern.ch/root/html/tutorials/graphics/canvas2.C.html)

I’m uploading the picture, but I can’t upload it directly because this forum doesn’t allow eps format, and the problem does not occur in png.  
[DGLAP.eps.zip](https://root-forum.cern.ch/uploads/default/original/2X/3/3e13e940885c988782d343a1944a91e87c1b900a.zip) (5.5 KB)

The first label of the second and third pad are dropping off.

Is there anything I can do about this? It’d be fine if I could just remove the 0 labels from the second and third pad.

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:** [September 4, 2017, 1:19pm UTC](https://root-forum.cern.ch/t/labels-dropping-off-using-canvaspartition/26097/2 "2017-09-04T13:19:18Z")

</div>

The latest version of this macro is here: [https://root.cern/doc/master/canvas2\_8C.html](https://root.cern/doc/master/canvas2_8C.html)  
It works as expected as you can see on the picture (which is generated every night using ROOT master).

---

<div class="post-metadata">

**Author:** ![rbvh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rbvh/32/13556_2.png) [@rbvh](https://root-forum.cern.ch/u/rbvh)\
**Post date:** [September 4, 2017, 1:35pm UTC](https://root-forum.cern.ch/t/labels-dropping-off-using-canvaspartition/26097/3 "2017-09-04T13:35:42Z")

</div>

Hi couet,

The macro only works in those cases because there is no label attached to the very left of every x-axis. My plots start from zero, which is when the issue occurs. I replaced the macro with the new one you linked to, but it made no difference.

---

<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:** [September 4, 2017, 6:27pm UTC](https://root-forum.cern.ch/t/labels-dropping-off-using-canvaspartition/26097/4 "2017-09-04T18:27:50Z")

</div>

I’m afraid there is no automatic solution.  
You will need to manually change the x-axis minimum (or your histogram x-axis minimum) and then the number which is truncated will also be moved in the picture (so it will either entirely disappear or it will become entirely visible).

BTW. People usually meet this problem with the y-axis:

> [@Ratio plot](https://root-forum.cern.ch/t/ratio-plot/9439/8):
>
> I assume that the problem is in the “vertical” direction (i.e. the upper part of the number is not visible). In this case, if you change the axis maximum (or your histogram maximum), the number which is truncated will also be moved in the picture (so it will either entirely disappear or it will become entirely visible). Unless the problem is in the “horizontal” direction (e.g. that the left part of the number is not drawn).

---

<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:** [September 6, 2017, 8:39am UTC](https://root-forum.cern.ch/t/labels-dropping-off-using-canvaspartition/26097/5 "2017-09-06T08:39:14Z")

</div>

The first label is cut off because it is clipped on the Pad edge. In the new `TRatioPlot` class we solved this issue by removing the labels on edges using the new method [ChangeLabel](https://root.cern/doc/master/classTGaxis.html#a8ef5ba035d846add3902cd714336eaac) .

The following macro is a modified version of canvas2.C doing this trick.

[canvas3.C](https://root-forum.cern.ch/uploads/default/original/2X/0/0179ac9b1a9214b46ed80cc48d18d66c615c1b1b.C) (5.1 KB)

Note that ChangeLabel can do mush more than simply removing a Label.

---

<div class="post-metadata">

**Author:** ![rbvh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rbvh/32/13556_2.png) [@rbvh](https://root-forum.cern.ch/u/rbvh)\
**Post date:** [September 6, 2017, 8:53am UTC](https://root-forum.cern.ch/t/labels-dropping-off-using-canvaspartition/26097/6 "2017-09-06T08:53:22Z")

</div>

Thanks couet and Wile\_E\_Coyote,

I managed to remove the 0 by settings the start of the histogram to 0.001, but I’ll look into the macro as well.

---

<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:** [September 6, 2017, 8:56am UTC](https://root-forum.cern.ch/t/labels-dropping-off-using-canvaspartition/26097/7 "2017-09-06T08:56:48Z")

</div>

Note that if you want to keep the 0 you can also change the label alignment instead of removing it:

```auto
         hFrame->GetXaxis()->ChangeLabel(1,-1,-1.,11.); // the first label is left aligned
         hFrame->GetXaxis()->ChangeLabel(-1,-1,0.); // remove the last label

```

---

<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:** [September 20, 2017, 8:56am UTC](https://root-forum.cern.ch/t/labels-dropping-off-using-canvaspartition/26097/8 "2017-09-20T08:56:54Z")

</div>

Closed on September 20, 2017, 8:56am UTC

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