SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: GoogleWind <goo...@16...> - 2015年05月12日 06:20:13
Hi everyone!
It is cool to use the pcolormesh in matplotlib. However, is there a way to
get the i, j indexes of the clicked cell? I have try event.mouseevent.xdata
and event.mouseevent.x. But they did not return the index I need.
Thanks in advanced for your help.
Dr. Jiacong Huang
Nanjing Institute of Geography & Limnology
Chinese Academy of Sciences
73 East Beijing Road, Nanjing 210008, China
Tel./Fax: +86-25-86882127
Homepage: http://www.escience.cn/people/elake/index.html
---Code to generate pcolormesh-------------------------------
import numpy as np
from matplotlib.pyplot import figure, show
from numpy import ma
n = 12
x = np.linspace(-1.5,1.5,n)
y = np.linspace(-1.5,1.5,n*2)
X,Y = np.meshgrid(x,y);
Qx = np.cos(Y) - np.cos(X)
Qz = np.sin(Y) + np.sin(X)
Qx = (Qx + 1.1)
Z = np.sqrt(X**2 + Y**2)/5;
Z = (Z - Z.min()) / (Z.max() - Z.min())
# The color array can include masked values:
Zm = ma.masked_where(np.fabs(Z) > 100, Z)
fig = figure()
ax = fig.add_subplot(111)
col = ax.pcolormesh(Qx[:5,:4],Qz[:5,:4],Zm[:4,:3])
show()
-------------------------
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/How-to-get-the-value-of-a-cell-in-pcolormesh-tp45499.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Thomas C. <tca...@gm...> - 2015年05月24日 18:58:55
To get the index of the grid you clicked on requires some knowledge of what
artist you are working with.
See https://github.com/matplotlib/matplotlib/pull/3989 for some brand new
code which makes this easier to implement in a general way.
While we catch up with that you will need to implement your own mapping of
x/y in data space -> i, j See
http://matplotlib.org/examples/api/image_zcoord.html for an example.
Tom
On Tue, May 12, 2015 at 2:21 AM GoogleWind <goo...@16...> wrote:
> Hi everyone!
> It is cool to use the pcolormesh in matplotlib. However, is there a way to
> get the i, j indexes of the clicked cell? I have try
> event.mouseevent.xdata
> and event.mouseevent.x. But they did not return the index I need.
>
> Thanks in advanced for your help.
>
> Dr. Jiacong Huang
> Nanjing Institute of Geography & Limnology
> Chinese Academy of Sciences
> 73 East Beijing Road, Nanjing 210008, China
> Tel./Fax: +86-25-86882127
> Homepage: http://www.escience.cn/people/elake/index.html
>
>
>
> ---Code to generate pcolormesh-------------------------------
> import numpy as np
> from matplotlib.pyplot import figure, show
> from numpy import ma
>
> n = 12
> x = np.linspace(-1.5,1.5,n)
> y = np.linspace(-1.5,1.5,n*2)
> X,Y = np.meshgrid(x,y);
> Qx = np.cos(Y) - np.cos(X)
> Qz = np.sin(Y) + np.sin(X)
> Qx = (Qx + 1.1)
> Z = np.sqrt(X**2 + Y**2)/5;
> Z = (Z - Z.min()) / (Z.max() - Z.min())
>
> # The color array can include masked values:
> Zm = ma.masked_where(np.fabs(Z) > 100, Z)
>
> fig = figure()
> ax = fig.add_subplot(111)
> col = ax.pcolormesh(Qx[:5,:4],Qz[:5,:4],Zm[:4,:3])
> show()
> -------------------------
>
>
>
> --
> View this message in context:
> http://matplotlib.1069221.n5.nabble.com/How-to-get-the-value-of-a-cell-in-pcolormesh-tp45499.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: GoogleWind <goo...@16...> - 2015年05月25日 03:36:02
Hi Tom,
It is nice to receive your hints. I would like to try it.
Best regards,
Jiacong Huang
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/How-to-get-the-value-of-a-cell-in-pcolormesh-tp45499p45610.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /