Dear Jonathan,

a late reply: just to say that what you outline below works well - thank you.

Best wishes,

Hans



On Fri, 27 May 2011, Jonathan Guyer wrote:



On May 27, 2011, at 10:15 AM, Fangohr H. wrote:

we are currently using the fipy.Viewer class to visualise a scalar field as a 
function of time (as was demonstrated in the diffusion example provided by 
fipy); example code attached below.

In addition, I would like to mark a particular x,y position on that plot which 
changes from iteration to iteration.

If I was not using fipy, I could use matplotlib to update for every iteration a 
plot of using

plot( [x], [y], 'o')

to plot a circle at position (x,y), say.

Sure, that's doable.


I couldn't make this work together with fipy -- presumably because fipy wraps 
up some matplotlib functionality to make things more convenient.

It does, but we've recently added the ability to more easily access the 
matplotlib internals for exactly this sort of use. You can see how to tell FiPy 
to use a particular set of matplotlib axes at:

 
http://www.ctcms.nist.gov/fipy/fipy/generated/viewers.matplotlibViewer.html#module-fipy.viewers.matplotlibViewer

You need to specify that you want a MatplotlibViewer instead of a general 
Viewer, and pass it the axes you want it to use. You are then free to 
manipulate those axes in any way you wish. In your script, you could do:

from matplotlib import pyplot
fig = pyplot.figure()
ax = fig.add_axes((0.1, 0.1, 0.8, 0.8))
viewer = fipy.MatplotlibViewer(vars=phi, datamin=-phi_outside*1., 
datamax=phi_outside*1, axes=ax)

and then

ll = []
for step in range(steps):
..     eq.solve(var=phi,
..              boundaryConditions=BCs,
..             dt=timeStepDuration)
..     for l in ll:
..         l.remove()
..     ll = ax.plot([step*0.2], [20 - step*0.15], 'ro')
..     viewer.plot()


Thanks in advance, and thank you for providing fipy and the user support.

our pleasure





--
Hans Fangohr
School of Engineering Sciences
University of Southampton
Phone: +44 (0) 238059 8345

Email: [email protected]
http://www.soton.ac.uk/~fangohr



Reply via email to