The error is exactly correct, ax is not defined. What did you think “ax” was supposed to be? axvline and axhline are both part of matplotlib.pyplot, so you want
plt.axvline(xpress, c=‘b’)
plt.axhline(ypress, c=‘b’)
but I can’t guess what the “ax.lines = ” is supposed to do. Did you copy this code from somewhere else?
i try to move rectangel patch with mouse all time when i move mouse the rectangle can’t move with and i have this error :
File “/home//nct.py”, line 16, in on_press
ax.lines =
NameError: name ‘ax’ is not defined
that my code with resulta but i need to know how can move rectangle with mouse i don’t know how fix problem
The error is exactly correct, ax is not defined. What did you think “ax” was supposed to be? axvline and axhline are both part of matplotlib.pyplot, so you want
plt.axvline(xpress, c=‘b’)
plt.axhline(ypress, c=‘b’)
but I can’t guess what the “ax.lines = ” is supposed to do. Did you copy this code from somewhere else?
—
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
Can you really not see the difference between that example and the code you wrote? I could tell you how to fix it, but I really think you need to be able to spot the problem yourself.
Look at the original code. In their on_press event, they refer to two global variables: ax, and fig. Those globals are created by the code later on in the file. In your code, you create "fig", but you decided not to create "ax". You used a different name. That's the problem.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.