[Matplotlib-devel] Need some help in 3D surface plotting...

Adrien VINCENT vincent.adrien at gmail.com
Tue Mar 13 11:16:44 EDT 2018


Hi Phani,

I would make the same analysis and suggestion as Ben about the error that you got.

About the color map, any rather recent version of Matplotlib (let's say 1.5.3+ or 2+) should have a list of color maps close to the list here:
https://matplotlib.org/tutorials/colors/colormaps.html
A few of them may be missing if you are not using Matplotlib 2.2+, but that is really a few of them.

As your data seem to have only values of the same sign, I would advise for any sequential color scheme rather than a diverging one like "coolwarm" (except if the mid-range value has a very specific meaning that you would want to emphasize). The point of the "viridis" family¹ ("viridis", "inferno", "plasma", "magma", and recently "cividis") is to be perceptually uniform, which should thus be felt quite the same in color or gray scale printing, as well as by colorblind people.

Best,
Adrien


On March 13, 2018 6:29:07 AM PDT, Benjamin Root <ben.v.root at gmail.com> wrote:
>The error message means you have an old version of matplotlib. Inferno
>was
>added in version 1.5. We are currently at verson 2.2.1 (supposedly will
>be
>released today?). I would also wonder if your install of numpy is old
>as
>well. Chances are, you are hitting on some old forgotten bug. Could you
>try
>updating your packages?
>
>On Tue, Mar 13, 2018 at 6:49 AM, phanids <phanikumar.ds at gmail.com>
>wrote:
>
>> Hi Adrien,
>>
>> Thanks a lot. I tried your suggestion and initial got
>>
>> root at phani:/home/pi/SampleExample# python Trial1.py
>> Traceback (most recent call last):
>>   File "Trial1.py", line 46, in <module>
>>     surf = ax.plot_surface(xx, yy, zz, cmap="inferno")
>>   File
>"/usr/lib/python2.7/dist-packages/mpl_toolkits/mplot3d/axes3d.py",
>> line 1637, in plot_surface
>>     polyc = art3d.Poly3DCollection(polys, *args, **kwargs)
>>   File
>"/usr/lib/python2.7/dist-packages/mpl_toolkits/mplot3d/art3d.py",
>> line 476, in __init__
>>     PolyCollection.__init__(self, verts, *args, **kwargs)
>>   File "/usr/lib/python2.7/dist-packages/matplotlib/collections.py",
>line
>> 799, in __init__
>>     Collection.__init__(self, **kwargs)
>>   File "/usr/lib/python2.7/dist-packages/matplotlib/collections.py",
>line
>> 107, in __init__
>>     cm.ScalarMappable.__init__(self, norm, cmap)
>>   File "/usr/lib/python2.7/dist-packages/matplotlib/cm.py", line 197,
>in
>> __init__
>>     self.cmap = get_cmap(cmap)
>>   File "/usr/lib/python2.7/dist-packages/matplotlib/cm.py", line 163,
>in
>> get_cmap
>>     % (name, ', '.join(cmap_d.keys())))
>> ValueError: Colormap inferno is not recognized. Possible values are:
>> Spectral, summer, coolwarm, Wistia_r, pink_r, Set1, Set2, Set3,
>brg_r,
>> Dark2, prism, PuOr_r, afmhot_r, terrain_r, PuBuGn_r, RdPu,
>gist_ncar_r,
>> gist_yarg_r, Dark2_r, YlGnBu, RdYlBu, hot_r, gist_rainbow_r,
>gist_stern,
>> PuBu_r, cool_r, cool, gray, copper_r, Greens_r, GnBu, gist_ncar,
>spring_r,
>> gist_rainbow, gist_heat_r, Wistia, OrRd_r, CMRmap, bone,
>gist_stern_r,
>> RdYlGn, Pastel2_r, spring, terrain, YlOrRd_r, Set2_r, winter_r, PuBu,
>> RdGy_r, spectral, rainbow, flag_r, jet_r, RdPu_r, gist_yarg, BuGn,
>> Paired_r,
>> hsv_r, bwr, cubehelix, Greens, PRGn, gist_heat, spectral_r, Paired,
>hsv,
>> Oranges_r, prism_r, Pastel2, Pastel1_r, Pastel1, gray_r, jet,
>Spectral_r,
>> gnuplot2_r, gist_earth, YlGnBu_r, copper, gist_earth_r, Set3_r, OrRd,
>> gnuplot_r, ocean_r, brg, gnuplot2, PuRd_r, bone_r, BuPu, Oranges,
>RdYlGn_r,
>> PiYG, CMRmap_r, YlGn, binary_r, gist_gray_r, Accent, BuPu_r,
>gist_gray,
>> flag, bwr_r, RdBu_r, BrBG, Reds, Set1_r, summer_r, GnBu_r, BrBG_r,
>Reds_r,
>> RdGy, PuRd, Accent_r, Blues, autumn_r, autumn, cubehelix_r,
>> nipy_spectral_r,
>> ocean, PRGn_r, Greys_r, pink, binary, winter, gnuplot, RdYlBu_r, hot,
>> YlOrBr, coolwarm_r, rainbow_r, Purples_r, PiYG_r, YlGn_r, Blues_r,
>> YlOrBr_r,
>> seismic, Purples, seismic_r, RdBu, Greys, BuGn_r, YlOrRd, PuOr,
>PuBuGn,
>> nipy_spectral, afmhot
>> root at bitscope:/home/pi/SampleExample#
>>
>> So I thought the color scheme "inferno" is not supported (or may be
>not
>> installed in my pi). So I changed it to "coolwarm" and I see the
>image as
>> below.
>>
>> <http://matplotlib.1069221.n5.nabble.com/file/t5142/plasma.png>
>>
>> Though this is way better than my initial version, still I see only 2
>color
>> combination... may be I need to check with color schemes provided in
>the
>> error message.
>>
>> Thanks a lot any way. Also let me know if you think any suitable
>color
>> scheme for this kind of gradient.
>>
>> Will check with you on other technical questions after I finish this.
>>
>> Thanks again,
>>
>> With best regards,
>> Phani.
>>
>>
>>
>> --
>> Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-devel-
>> f28077.html
>> _______________________________________________
>> Matplotlib-devel mailing list
>> Matplotlib-devel at python.org
>> https://mail.python.org/mailman/listinfo/matplotlib-devel
>>

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.


More information about the Matplotlib-devel mailing list