Hi,
Sorry haven't used ipython, so not sure if there is another/better
ipython way.
Attached is how I solved it in normal python.
I added a "next line" button to the graph, and set the ydata for the
line each time the button is pushed.
There is a couple of set_ylim lines commented out, depending on the
nature of your data, it might be appropriate to uncomment one of those,
however the set_aspect line may might mean the graph is very tall and
skinny with the supplied data.
Hope that gives you some ideas for your own code.
Steve
On 21/04/2010 3:35 AM, tomislav_ma...@gmx.com wrote:
Hello everyone,
if I read a column file like this (simplified to integers):
0 1 2 3
1 2 3 4
2 3 4 5
3 4 5 6
with: "data = np.loadtxt("fileName")", why can't I use a for loop
inside ipython (started with "-pylab" option) to plot each of the
Line2D objects and then draw them on the plot? I am using matplotlib
to debug a computational geometry code and I would like these lines to
plot paused by the user input so that I can identify when (where)
exactly the wrong calculations happen:
import numpy as np
import matplotlib.pyplot as plt
fig1 = plt.figure()
ax1 = fig1.add_subplot(111)
ax1.set_aspect("equal")
for line in data:
raw_input("press enter to plot the line")
ax1.plot([line[0],line[2]],[line[1],line[3]],'b')
plt.draw()
This way I could see with pressing e.g. the return key when my
calculations go wrong.... any advice?
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Button
imin = 9999
imax = 0
displayline = 0
data = np.loadtxt("fileName")
for line in data:
imin = min(imin, min(line))
imax = max(imax, max(line))
fig1 = plt.figure()
ax1 = fig1.add_subplot(111)
ax1.set_aspect("equal")
r, = ax1.plot(data[displayline],'b')
#ax1.set_ylim(imin , imax)
#where rect=[left, bottom, width, height] in normalized (0,1) units
controlax = fig1.add_axes([0.85, 0.1, 0.1, 0.04])
button = Button(controlax, 'Next Line')
def nextline(event):
global displayline
displayline += 1
if displayline >= len(data):
displayline = 0 #start cycle again
r.set_ydata(data[displayline])
#ax1.set_ylim(min(data[displayline]) , max(data[displayline]))
plt.draw()
button.on_clicked(nextline)
plt.show()
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users