Preproducing updating PlotShape() figures in

When Python is the interpreter, what is a good
design for the interface to the basic NEURON

Moderator: hines

Post Reply
Posts: 58
Joined: Sun Aug 02, 2015 4:28 am
Location: UK

Preproducing updating PlotShape() figures in

Post by RBJ »

Hi All,
I have had some success with accessing the PlotShape() function through Python in Jupyter and up dating it so I can see a pretty coloured wave of Vm traversing my test model (based on your own tutorials). To moviefy this, I can screen record it, however, usually with Python in other projects I save timeslices and then can gather these up as a movie or animation later. Is there a way to do this with NEURON 8.0. So perhaps that is a little garbled:
This produces a nice updating graphic:

Code: Select all

ps2 = h.PlotShape(True)
ps2.exec_menu('Shape Plot')
However I would like it saved frame by frame as PNG.... or equiv.
When I attempted Matplotlib:

Code: Select all

I am able to produce a 3D plot of sorts, but not really like the pretty coloured 2D image in the NEURON GUI window. And just at one point in time.
I realise I can programmatically collate this data and plot separately, but I don't want to re-invent the wheel if this is already built in...
Kindest Regards

NEURON 8.0 iMac latest OsX whatever that is....
Currently using Jupyter Notebook, Python 3.7
Posts: 229
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

Re: Preproducing updating PlotShape() figures in

Post by ramcdougal »

You don't have to use pyplot or plotly (I prefer the interactivity of plotly) for visualizing PlotShapes. If you have an existing process that worked with interviews windows, you can still use that. If you do use the pyplot version though, you can save to a png in the usual pyplot way, and use that to generate a series of images that you can convert to a video.

Here's an example of storing all the data from a simulation*, then expanding the diameters to make the cell more visible, using the regular interviews graphics with the saved simulation results, saving to postscript files, and then converting to images and finally to a video: ... / This is the resulting video:

(* In that code, there are Hodgkin-Huxley channels in a mammalian cell morphology. This is obviously not biologically realistic, but that wasn't the point.)

As an aside, and this can be in a private email if you prefer, I'm curious what we can do to make graphs with pyplot and plotly work better for you.
Post Reply