Zooming in on Image data plotted using matplotlib

Hi,

I am trying to oom in on the image data plotted in 2 subplots using
matplotlib. However, the zooming in needs to take into consideration both
the images which are being displayed in the subplot. If I have 2 images on
the subplot, I can click any one of these images. I then get the x and y
coordinates. But I am not sure how to open a new window with the clicked
coordinates and 5 or 10 pixels around the clicked coordinates and display
it in a new window.

Could someone please help me out?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180401/3413cfa2/attachment.html>

You can't get that feature out-of-the-box, but it is possible to construct
such a feature with some work. You can create callbacks functions that take
x/y coordinates to create a new figure window with remade imshow()'s. You
might want to consider picking up a copy of my book, "Interactive
Applications using Matplotlib", particularly focusing on chapter 2 on the
callback system.

I hope that helps!
Ben Root

···

On Sun, Apr 1, 2018 at 6:08 PM, Sab VS <sabvs647 at gmail.com> wrote:

Hi,

I am trying to oom in on the image data plotted in 2 subplots using
matplotlib. However, the zooming in needs to take into consideration both
the images which are being displayed in the subplot. If I have 2 images on
the subplot, I can click any one of these images. I then get the x and y
coordinates. But I am not sure how to open a new window with the clicked
coordinates and 5 or 10 pixels around the clicked coordinates and display
it in a new window.

Could someone please help me out?

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180402/a33295ae/attachment.html>

I want to second Ben's email: I highly recommend his book. I fumbled
around for a long time with minor interactive matplotlib features. Then
I read his book and it completely clarified my mental model of mpl
interactivity and, indeed, of GUIs in general. Thanks Ben!
Here's an excerpt that describes my situation quite well:

"""
Indeed, given that the primary audience for Matplotlib is scientific
programmersfor whom GUIs are, at best, an afterthought, Matplotlib provides a
gradual curveto create full-fledged GUI applications. For simple GUI tasks, one can
go quite far with Matplotlib without ever having to adopt a GUI
platform. And, as we will see in the next chapter, taking those final
steps into a GUI application would not require getting rid of any
existing code."""

Juan.

···

On Tue, Apr 3, 2018, at 12:17 PM, Benjamin Root wrote:

You can't get that feature out-of-the-box, but it is possible to
construct such a feature with some work. You can create callbacks
functions that take x/y coordinates to create a new figure window with
remade imshow()'s. You might want to consider picking up a copy of my
book, "Interactive Applications using Matplotlib", particularly
focusing on chapter 2 on the callback system.> I hope that helps!
Ben Root

On Sun, Apr 1, 2018 at 6:08 PM, Sab VS <sabvs647 at gmail.com> wrote:

Hi,
I am trying to oom in on the image data plotted in 2 subplots using
matplotlib. However, the zooming in needs to take into consideration
both the images which are being displayed in the subplot. If I have 2
images on the subplot, I can click any one of these images. I then
get the x and y coordinates. But I am not sure how to open a new
window with the clicked coordinates and 5 or 10 pixels around the
clicked coordinates and display it in a new window.>>
Could someone please help me out?

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

_________________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180403/a9c4b0dd/attachment.html>

hi
i am workind on the thread "filling"
since a cuple of months i did not use Matplotlib
i have difficulties to get comfortable with simple lines of code
for example (end of this mail)
- why do the circle appear so big whereas the dimension of the picture are [0,5] for x and for y and the radius of the circle is 0.05 ?
- why, if i cancel the paragraph named "oeil......", do the circle disappear ?
thanks for your help...

figur generated :

lines of code :

···

-----
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

# quelques param?tres par d?faut
plt.style.use('bmh')
mpl.rcParams['font.family'] = 'STIXGeneral'
plt.rcParams["font.size"] = 10

# dimensions ? choisir
xmin,xmax,ymin,ymax=0,5,0,5
(L,l)=(7,7)

# fenetrages divers
Linch,linch=(L/2.54,l/2.54)
fig, lafigure = plt.subplots(figsize=(Linch,linch))
Lx,x,Ly,y=[],xmin,[],ymin
while (x<=xmax):
    Lx.append(x)
    x+=1
while (y<=ymax):
    Ly.append(y)
    y+=1

#oeil.............
X1 = np.linspace(1-np.sqrt(2),1+np.sqrt(2), 256,endpoint=True)
Y1 = np.sqrt(2-X1**2)
lafigure.plot(X1, Y1, color="black", linewidth=0.5, linestyle="-")
lafigure.plot(X1, 1-Y1, color="black", linewidth=0.5, linestyle="-")

# trac? d'un cercle
r=0.05
lafigure.add_patch(mpl.patches.Circle((r, r),1,color ='black', linewidth=0.5, fill=False,linestyle="--"))

plt.axis('off')
lafigure.spines['right'].set_visible(True)
plt.show()

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180406/04c74b37/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-7.png
Type: image/png
Size: 42418 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180406/04c74b37/attachment-0001.png>

Le 06/04/2018 ? 06:29, Vincent Douce Mathoscope a ?crit?:

hi
i am workind on the thread "filling"
since a cuple of months i did not use Matplotlib
i have difficulties to get comfortable with simple lines of code
for example (end of this mail)
- why do the circle appear so big whereas the dimension of the picture
are [0,5] for x and for y and the radius of the circle is 0.05 ?

* The dimensions of your *figure*? are of 2.75 inches (7/2.54).
* [0, 5] for xmin, xmax etc. are your conventional units within axes,
not related to figsize.
* The radius of your Circle patch is 1 ; ?? (0.05,0.05) is its center.

- why, if i cancel the paragraph named "oeil......", do the circle
disappear ?

* I don't see any disappearance. If you "close your eye", the two plots
of sqrt(whatever) are eliminated, but the patch is still there. Only
Matplotlib redefines the scale of the plot, the circle becomes bigger,
and a smaller fragment is plotted.
Notice that you never fix the scales using axis(…).

Bon courage.

Jerzy Karczmarczuk
/Caen/

Hi Vincent,

I think that Jerzy got the correct answer about your issue with the
circle patch. The docstrings reads indeed:

mpl.patches.Circle(xy, radius=5, **kwargs)
Create true circle at center *xy* = (*x*, *y*) with given *radius*.

I did not notice any disappearance when commenting the "oeil" section
either :/.

(Attached is a script based on yours that gives the attached PNG.)

Best regards,
Adrien

Le 06/04/2018 ? 06:29, Vincent Douce Mathoscope a ?crit?:

hi
i am workind on the thread "filling"
since a cuple of months i did not use Matplotlib
i have difficulties to get comfortable with simple lines of code
for example (end of this mail)
- why do the circle appear so big whereas the dimension of the picture
are [0,5] for x and for y and the radius of the circle is 0.05 ?

* The dimensions of your *figure*? are of 2.75 inches (7/2.54).
* [0, 5] for xmin, xmax etc. are your conventional units within axes,
not related to figsize.
* The radius of your Circle patch is 1 ; ?? (0.05,0.05) is its center.

- why, if i cancel the paragraph named "oeil......", do the circle
disappear ?

* I don't see any disappearance. If you "close your eye", the two plots
of sqrt(whatever) are eliminated, but the patch is still there. Only
Matplotlib redefines the scale of the plot, the circle becomes bigger,
and a smaller fragment is plotted.
Notice that you never fix the scales using axis(…).

Bon courage.

Jerzy Karczmarczuk
/Caen/

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: exemple_cercle.py
Type: text/x-python
Size: 2356 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180406/47f81ea8/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: exemple_cercle.png
Type: image/png
Size: 9197 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180406/47f81ea8/attachment.png>

···

On 04/06/2018 01:01 AM, Jerzy Karczmarczuk wrote:

Also see the examples in
https://matplotlib.org/gallery/index.html#event-handling the event-handling
section of the docs.

Tom

···

On Tue, Apr 3, 2018 at 9:56 AM Juan Nunez-Iglesias <jni.soma at gmail.com> wrote:

I want to second Ben's email: I highly recommend his book. I fumbled
around for a long time with minor interactive matplotlib features. Then I
read his book and it completely clarified my mental model of mpl
interactivity and, indeed, of GUIs in general. Thanks Ben!

Here's an excerpt that describes my situation quite well:

"""
Indeed, given that the primary audience for Matplotlib is scientific
programmers
for whom GUIs are, at best, an afterthought, Matplotlib provides a gradual
curve
to create full-fledged GUI applications. For simple GUI tasks, one can go
quite far with Matplotlib without ever having to adopt a GUI platform. And,
as we will see in the next chapter, taking those final steps into a GUI
application would not require getting rid of any existing code.
"""

Juan.

On Tue, Apr 3, 2018, at 12:17 PM, Benjamin Root wrote:

You can't get that feature out-of-the-box, but it is possible to construct
such a feature with some work. You can create callbacks functions that take
x/y coordinates to create a new figure window with remade imshow()'s. You
might want to consider picking up a copy of my book, "Interactive
Applications using Matplotlib", particularly focusing on chapter 2 on the
callback system.
I hope that helps!
Ben Root

On Sun, Apr 1, 2018 at 6:08 PM, Sab VS <sabvs647 at gmail.com> wrote:

Hi,
I am trying to oom in on the image data plotted in 2 subplots using
matplotlib. However, the zooming in needs to take into consideration both
the images which are being displayed in the subplot. If I have 2 images on
the subplot, I can click any one of these images. I then get the x and y
coordinates. But I am not sure how to open a new window with the clicked
coordinates and 5 or 10 pixels around the clicked coordinates and display
it in a new window.

Could someone please help me out?

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

*_______________________________________________*
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180413/8ed5ae6f/attachment.html>

Thnaks for the help.

···

On Fri, Apr 13, 2018 at 5:18 PM, Thomas Caswell <tcaswell at gmail.com> wrote:

Also see the examples in https://matplotlib.org/gallery/index.html#event-
handling the event-handling section of the docs.

Tom

On Tue, Apr 3, 2018 at 9:56 AM Juan Nunez-Iglesias <jni.soma at gmail.com> > wrote:

I want to second Ben's email: I highly recommend his book. I fumbled
around for a long time with minor interactive matplotlib features. Then I
read his book and it completely clarified my mental model of mpl
interactivity and, indeed, of GUIs in general. Thanks Ben!

Here's an excerpt that describes my situation quite well:

"""
Indeed, given that the primary audience for Matplotlib is scientific
programmers
for whom GUIs are, at best, an afterthought, Matplotlib provides a
gradual curve
to create full-fledged GUI applications. For simple GUI tasks, one can go
quite far with Matplotlib without ever having to adopt a GUI platform. And,
as we will see in the next chapter, taking those final steps into a GUI
application would not require getting rid of any existing code.
"""

Juan.

On Tue, Apr 3, 2018, at 12:17 PM, Benjamin Root wrote:

You can't get that feature out-of-the-box, but it is possible to
construct such a feature with some work. You can create callbacks functions
that take x/y coordinates to create a new figure window with remade
imshow()'s. You might want to consider picking up a copy of my book,
"Interactive Applications using Matplotlib", particularly focusing on
chapter 2 on the callback system.
I hope that helps!
Ben Root

On Sun, Apr 1, 2018 at 6:08 PM, Sab VS <sabvs647 at gmail.com> wrote:

Hi,
I am trying to oom in on the image data plotted in 2 subplots using
matplotlib. However, the zooming in needs to take into consideration both
the images which are being displayed in the subplot. If I have 2 images on
the subplot, I can click any one of these images. I then get the x and y
coordinates. But I am not sure how to open a new window with the clicked
coordinates and 5 or 10 pixels around the clicked coordinates and display
it in a new window.

Could someone please help me out?

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

*_______________________________________________*
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180418/f8593d4b/attachment.html>