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. |