Problem plotting PlotShape

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

Moderator: hines

Post Reply
fvarkevisser
Posts: 4
Joined: Tue Sep 21, 2021 3:36 pm

Problem plotting PlotShape

Post by fvarkevisser »

Hi everyone,

I am having trouble plotting a PlotShape in python using pyplot.
Below is a very simple example according to the documentation:

Code: Select all

from neuron import h
from matplotlib import pyplot

main = h.Section(name='main')
dend = h.Section(name='dend')
dend.connect(main)

ps = h.PlotShape(False)
ps.plot(pyplot)
pyplot.show()
Running this gives me the following error:

Code: Select all

Traceback (most recent call last):

  File "path\to\file", line 16, in <module>
    ps.plot(pyplot)

  File "c:\nrn\lib\python\neuron\__init__.py", line 1147, in __call__
    return _do_plot_on_matplotlib_figure(fig)

  File "c:\nrn\lib\python\neuron\__init__.py", line 1005, in _do_plot_on_matplotlib_figure
    variable, varobj, lo, hi, secs = get_plotshape_data(ctypes.py_object(self._data))

OSError: exception: access violation reading 0x0000000000000010
Is there someone who can point out what goes wrong here?

Many thanks!
ted
Site Admin
Posts: 5960
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Problem plotting PlotShape

Post by ted »

Works for me under CentOS 7 with Python 3.6.8 and NEURON 8.0a-575-gd9462cc master (d9462cc) 2021-05-27 (installed from source code). Also works under Mint 20.1 with Python 3.8 and NEURON 8.0.0 HEAD (429d11ef) 2021-04-30 (installed via pip). That said, both cases generated a MatplotlibDeprecationWarning about "setting the line's pick radius".

What versions of MSWin, NEURON, and Python are you using?
fvarkevisser
Posts: 4
Joined: Tue Sep 21, 2021 3:36 pm

Re: Problem plotting PlotShape

Post by fvarkevisser »

Hi Ted,

Thanks for your reply.
I am running Python 3.9.4 with NEURON 8.0 installed via pip on Windows 10.

I have also tried it on my macOs (Big Sur 11.2.3), running python 3.9.1 and NEURON 8.0.0 installed using pip.
This also gave me an error but actually another one:

Code: Select all

Segmentation fault: 11
I'm not sure if the two errors are related.
fvarkevisser
Posts: 4
Joined: Tue Sep 21, 2021 3:36 pm

Re: Problem plotting PlotShape

Post by fvarkevisser »

On my Mac, I tried running it with python3.7 which worked fine.
So I guess the python version is causing trouble here.
ted
Site Admin
Posts: 5960
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Problem plotting PlotShape

Post by ted »

Or maybe the problem is with matplotlib. Can you try an earlier Python under MSWin?
fvarkevisser
Posts: 4
Joined: Tue Sep 21, 2021 3:36 pm

Re: Problem plotting PlotShape

Post by fvarkevisser »

Hi Ted,

Trying to run this on Python version 3.6.8 raises the following error:

Code: Select all

>>> from neuron import h
>>> import matplotlib as pyplot
>>> main = h.Section(name='main')
>>> dend = h.Section(name='dend')
>>> dend.connect(main)
dend
>>> ps = h.PlotShape(False)
>>> ps.plot(pyplot)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\nrn\lib\python\neuron\__init__.py", line 1152, in __call__
    raise NotImplementedError
Post Reply