clawpack/visclaw — pull request #40 by ketch (2013-07-15 03:23:19+00:00)
Title: Simple interactive plotting mode.

This PR adds an option for "simple" interactive plotting with Iplotclaw. I often find that I'd like to perform some post-processing and plotting that is difficult or impossible within visclaw's framework, but is easy to write with pure matplotlib and numpy. But I would like to use visclaw's interactive plotting mode, too.

With this PR, I can define a simple plot function that operates on a Solution object, like:

def plotfun(sol):
import matplotlib.pyplot as plt
x = sol.state.grid.x.centers
plt.plot(x,sol.q[0,:])

and then use it in interactive mode via

import plotfun
from clawpack.visclaw import Iplotclaw
ip = Iplotclaw.Iplotclaw(setplot=plotfun,outdir='./_output',simple=True)
ip.plotloop()

I simply pass my plotting function in place of setplot and use the keyword argument simple=True. Overloading setplot here may be a bit hacky, and I'm not sure that everything works, though I have tested the basic functionality.