PlotShape colormap

Using the graphical user interface to build and exercise models. Includes customizing the GUI by writing a little bit of hoc.
Post Reply
Posts: 34
Joined: Thu Feb 02, 2017 11:30 am

PlotShape colormap

Post by bschneiders »

Hi, is there are way to make PlotShapes have different colormaps? I changed the color scheme for one plotshape (for fluorescence - I want it to be a single hue) and it ended up changing the rest of them. Is there any way around this, or is colormap a global setting? Thanks!

Also, my method for doing this was pretty clunky. I saved a list of RGB values from a colorbrewer site, and plugged them in to the colormap line by line. If there is a preferred way to do it that gets around the above issue, please let me know!

Code: Select all

greenlist = [[247,252,245],
for i in range(len(greenlist)):
    l = [i]+greenlist[i]
Posts: 229
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

Re: PlotShape colormap

Post by ramcdougal »

The documentation says that colormaps are local by default. If they're not, maybe you could try explicitly setting/unsetting the global flag when you define the size of your colormap before setting its values.

For what it's worth, you can change the default colormap for all of your plotshapes by editing your nrn.def defaults file. See: ... ormap.html

Matplotlib has a large selection of colormaps; you can get your colors from there. See ... rence.html for a list of their colormaps and what they look like, and see ... matplotlib for code for extracting the rgb values from their colormaps.

If you're using NEURON 7.7+, you can have your PlotShape render on a matplotlib figure and use their colormaps directly on a per PlotShape basis with the cmap keyword argument:

Code: Select all

from matplotlib import pyplot, cm
ps = h.PlotShape(list(h.allsec()), False)
ps.scale(-80, 40)
ax = ps.plot(pyplot, cmap=cm.jet)
This won't update, of course, but it does generate a 3d image you can rotate, etc.
Post Reply