Unfortunately the .plot for both matplotlib and plotly (available in 8.0 development version) does not currently support the .color or .color_list values and instead always color based on the value of some variable (v, by default).
(Note that you can use .mark as in the documentation to highlight specific locations, but I gather you want to highlight regions instead.)
One solution is of course to temporarily change the value of some variable (e.g. v) to be e.g. high in the apical dendrites and low elsewhere.
There is an undocumented method, _do_plot, of the .plot return objects that can help (matplotlib only for now, plotly works slightly differently). It requires 4 arguments: a low value, a high value, a list of sections, a variable to use for color coding -- or None -- and passes any keyword arguments to matplotlib. Thus, for example, if you've already plotted the whole shapeplot, you could color the h.apic sections red with:
Code: Select all
ps._do_plot(0, 1, h.apic, None, color='red')
(0 and 1 are the low and high values, respectively, but they're ignored since the variable is None.)
Here's a full working example and output:
Code: Select all
import urllib.request
from matplotlib import pyplot
from matplotlib.colors import ListedColormap
from neuron import h
# load a morphology from the web
with urllib.request.urlopen(
"https://senselab.med.yale.edu/modeldb/getModelFile?model=87284&AttrID=23&s=yes&file=/%2fCA1_abeta%2fc91662.ses"
) as response:
with open('c91662.ses', 'wb') as f:
f.write(response.read())
# load the morphology into NEURON
h.load_file('c91662.ses')
# get matplotlib plotshape with default coloring (for v)
ps = h.PlotShape(False).plot(pyplot)
# now go back and highlight the apics
ps._do_plot(0, 1, h.apic, None, color='red')
pyplot.show()
