# Zoom individual pads of a canvas in a GUI

**URL:** <https://root-forum.cern.ch/t/zoom-individual-pads-of-a-canvas-in-a-gui/41209>\
**Category:** Newbie\
**Created:** [August 30, 2020, 1:36am UTC](https://root-forum.cern.ch/t/zoom-individual-pads-of-a-canvas-in-a-gui/41209 "2020-08-30T01:36:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![rafopar](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rafopar/32/28234_2.png) [@rafopar](https://root-forum.cern.ch/u/rafopar)\
**Post date:** [August 30, 2020, 1:36am UTC](https://root-forum.cern.ch/t/zoom-individual-pads-of-a-canvas-in-a-gui/41209/1 "2020-08-30T01:36:46Z")

</div>

Hi,

I want to be able to zoom individual pads to see objects in individual pads better.  
When it is just a single canvas no sub psds, i.e. only one figure instead of 6, I use the  
`ProcessedEvent(Int_t event,Int_t ix, Int_t iy, TObject* selected)` of the TCanvas, where  
using ix and and iy of kButton1Down and kButton1Up and the c-\>GetRange(x\_0, y\_0, x\_1, y\_1), the frame range is modified accordingly.

However I am not sure what is the best way of doing this with multiple pads.  
For example in this plot I divided the canvas into 6 pads, but then realized that  
pad doesn’t have “ProcessedEvent” method.

Could you advise, if I should necessarily make a separate embedded canvas for each figure (which I want to avoid), or somehow I can do the “Zoom” using the pad.

In this figure drawn objects are TArc and TLine.

 ![Screenshot](https://root-forum.cern.ch/uploads/default/original/3X/6/4/64501596c3342d05e01a3909e0a07402f5080632.png)

_ROOT Version:_ 6.16/00  
_Platform:_ Not Provided  
_Compiler:_ gcc 7.5.0

* * *

---

<div class="post-metadata">

**Author:** ![StephanH](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@StephanH](https://root-forum.cern.ch/u/StephanH)\
**Post date:** [August 30, 2020, 9:09pm UTC](https://root-forum.cern.ch/t/zoom-individual-pads-of-a-canvas-in-a-gui/41209/2 "2020-08-30T21:09:25Z")

</div>

The expert on this is @couet, but he will probably be quite busy the next few days.

In the mean time, I would try to zoom the histogram that’s displayed on the pad in question. Something like

```auto
hist->GetXaxis()->SetRange[User](...);

```

Maybe you have to tell the pad that it has been modified after the zooming of the axis using `thePad->Modified();`

---

<div class="post-metadata">

**Author:** ![rafopar](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rafopar/32/28234_2.png) [@rafopar](https://root-forum.cern.ch/u/rafopar)\
**Post date:** [August 31, 2020, 3:57am UTC](https://root-forum.cern.ch/t/zoom-individual-pads-of-a-canvas-in-a-gui/41209/3 "2020-08-31T03:57:54Z")

</div>

Thank you @StephanH for the replay,

It is actually just a frame, not histogram nor graph.  
I just draw TArc and TLine on it.

Though my issue is, how to get coordinates in the local pad frame.  
from ProcessedEvent method of the canvas I can get coordinates in the global canvas,  
frame, but not of the pad on which that mouse operated.

---

<div class="post-metadata">

**Author:** ![StephanH](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@StephanH](https://root-forum.cern.ch/u/StephanH)\
**Post date:** [August 31, 2020, 7:57am UTC](https://root-forum.cern.ch/t/zoom-individual-pads-of-a-canvas-in-a-gui/41209/4 "2020-08-31T07:57:43Z")

</div>

Ok, we better wait for @couet to have a look at this.

---

<div class="post-metadata">

**Author:** ![rafopar](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rafopar/32/28234_2.png) [@rafopar](https://root-forum.cern.ch/u/rafopar)\
**Post date:** [August 31, 2020, 10:24am UTC](https://root-forum.cern.ch/t/zoom-individual-pads-of-a-canvas-in-a-gui/41209/5 "2020-08-31T10:24:40Z")

</div>

Thanks @StephanH !!, sure No rush.

---

<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 2, 2020, 9:18am UTC](https://root-forum.cern.ch/t/zoom-individual-pads-of-a-canvas-in-a-gui/41209/6 "2020-09-02T09:18:51Z")

</div>

I do not understand why you need to use `ProcessedEvent` to perform zooming.  
Interactive Zooming is already implemented … there is no code to write … just zoom with the mouse.  
I guess you are doing something special. Can you provide a piece of code reproducing what you are doing ?

---

<div class="post-metadata">

**Author:** ![rafopar](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rafopar/32/28234_2.png) [@rafopar](https://root-forum.cern.ch/u/rafopar)\
**Post date:** [September 2, 2020, 2:07pm UTC](https://root-forum.cern.ch/t/zoom-individual-pads-of-a-canvas-in-a-gui/41209/7 "2020-09-02T14:07:52Z")

</div>

Thank you for the replay.

I just uploaded a slightly modified version of exec3.C from the root tutorials.  
So on the right pad I draw a frame, and on that frame I draw to TArcs.  
In my case the mouse zoom doesn’t work. It will work if I zoom individual axises separately, when I hover the mouse in the vicinity of axises, but what I want is to zoom, like how it is done in TH2

[exec3\_Rafo.C](https://root-forum.cern.ch/uploads/short-url/xGHydnOrQ3qINAdIiM9DjjzhAOH.C) (1.3 KB)

---

<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 2, 2020, 2:16pm UTC](https://root-forum.cern.ch/t/zoom-individual-pads-of-a-canvas-in-a-gui/41209/8 "2020-09-02T14:16:52Z")

</div>

> [@rafopar](#):
>
> like how it is done in TH2

DrawFrame produces and empty TH1F… You need a TH2F. Instead of using DrawFrame create an empty TH2F and Draw it.

---

<div class="post-metadata">

**Author:** ![rafopar](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rafopar/32/28234_2.png) [@rafopar](https://root-forum.cern.ch/u/rafopar)\
**Post date:** [September 2, 2020, 6:06pm UTC](https://root-forum.cern.ch/t/zoom-individual-pads-of-a-canvas-in-a-gui/41209/9 "2020-09-02T18:06:38Z")

</div>

Thank you!

Yes With TH2 it worked!  
This mostly satisfies my needs.

Ont thing that I was envisioning is to keep the aspect ratio fixed, even, if user mouse zoom is changing the AR, I would like it keep the aspect ratio using the largest side.  
Is any option is available, that would allow me to do this?

Thanks,  
Rafo

---

<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 3, 2020, 6:55am UTC](https://root-forum.cern.ch/t/zoom-individual-pads-of-a-canvas-in-a-gui/41209/10 "2020-09-03T06:55:48Z")

</div>

> [@rafopar](#):
>
> This mostly satisfies my needs.

great !

> [@rafopar](#):
>
> Is any option is available, that would allow me to do this?

No, not directly. You will need to implement something.
