I have run the _Contour plots_ example at the top of http://scitools.org.uk/cartopy/docs/latest/matplotlib/advanced_plotting.html and I was surprised to get colors different from the ones in the example image displayed on the web page.
And then I realized that I was using matplolib 2.0.0 bundled with uvcdat 2.10 and that I was getting the new _viridis_ default colormap, instead of the old _jet_ default.
You may want to explicitely specify a _jet_ colormap in your examples, so that the users running the examples get the same image as what is displayed on the web page, e.g. replace
plt.contourf(lons, lats, sst, 60,
transform=ccrs.PlateCarree())
with
plt.contourf(lons, lats, sst, 60, cmap='jet',
transform=ccrs.PlateCarree())
I think we really don't want to do that actually. It would be preferable to use viridis for the examples instead. I expect this will be true for the next release, which fully supports matplotlib v2+.
Or you may want to explicitly specify a suitable colormap that is neither _jet_ nor _viridis_.
It's really a minor problem, but knowing that people will probably run the examples with both matplotlib <2 and >=2 for some time, it can be surprising if you run the script and get the viridis colormap when the web displays the jet colormap, or the reverse :-)
We'd like to encourage the adoption of colormaps other than jet, and viridis is nice because it is the new default for matplotlib. I think we should move forward and embrace that change. The change from jet to viridis is well documented by matplotlib, if users see jet when they expected viridis then they will hopefully know why. Therefore I'm in favour of leaving this as it is a building the docs for the next version with matplotlib v2.
@jypeter :+1: for consistency between docs and user experience!
Overall though, in this case I agree with @ajdawson - it really would be preferable to use viridis over jet.
Matplotlib have put together an excellent discussion on choosing colormaps that also helps explain why viridis is a good choice for a general colormap, and, by extension, why the old standard jet colormap is a much worse choice.
In addition, it is not just the default colormap that changes with matplotlib v2. If we wanted to make sure example plots look the same on 1.5 and 2 we'd have to set an awful lot of parameters in order to do so, which would obscure the ideas we're trying to get across in each example. To me this is another good reason to just use the defaults for the example plots (although I'll admit the colormap is by far the most noticeable change to the mpl defaults).
Well, I _try_ to read the documentations, since I'm supposed to help and advise other users, but you should not expect the (casual) users to know about the jet/viridis subtleties.
All the casual users usually want is _some kind of rainbow stuff_ and it's a good thing if the get the best rainbow stuff by default. Just need a consistent doc.
I have not used cartopy before (I used _basemap_ and _vcs_) so I won't know the differences with older cartopy+matplotlib combinations, unless what I get something different from what's on the web.
Oh, is this why I did not get dotted lines when running http://scitools.org.uk/cartopy/docs/latest/examples/arrows.html, and the meridians/parallels over the ocean were almost invisible? I was wondering what was wrong with my setup
See here for a list of Matplotlib v2 defaults changes. Also note that only the current master version of cartopy fully supports matplotlib v2, there may well be problems with v0.15 and lower. We expect to release Cartopy v0.16 very soon which will support Matplotlib 2 properly.
@jypeter Given that generic "rainbow stuff" is outright hostile to users with color vision deficiency, not to mention won't print in greyscale, while viridis will do those things, viridis is absolutely the correct choice in lieu of something field appropriate, like is used in cmocean.
Thanks @dopplershift for the link to cmocean! Do you you know if somebody has developed or documented similar colormaps for the atmosphere or other _realms_ (in the CMIP sense)?
I will try to spend more time advertising the new trends in colormaps usage
Meanwhile, we still have the problem that there is, as @dkillick put it, a problem of _consistency between docs and user experience_ , depending on which version of matplotlib you use, and which version of the cartopy web site you access. So, either you leave things as they are, or you replace
plt.contourf(lons, lats, sst, 60,
transform=ccrs.PlateCarree())
with
plt.contourf(lons, lats, sst, 60,
# Note: the 'viridis' colormap replaces 'jet' as the default colormap in matplotlib>=2
# <add a link here to a place comparing jet vs viridis>
# Explicitly specifying cmap below ensures that people running this example
# script will get the recommended colormap, even if they use an earlier version of matplotlib
cmap='viridis',
transform=ccrs.PlateCarree())
It's a bit awkward and you would have to decide if you'll do this only in this example, or on all similar examples. I'm not sure there is a good way to do this
馃憤 to explicitly setting viridis.
I'd like to have the equivalent to cmocean in MetPy.
In addressing this, I'd simply change the default colormap being used when building the cartopy docs. The solution would be almost identical to the one proposed at https://github.com/SciTools/iris/pull/2909/files.
I'm 馃憤 on doing this.
The docs seem to be using viridis to me now, so I'm going to close this.
Most helpful comment
We'd like to encourage the adoption of colormaps other than jet, and viridis is nice because it is the new default for matplotlib. I think we should move forward and embrace that change. The change from jet to viridis is well documented by matplotlib, if users see jet when they expected viridis then they will hopefully know why. Therefore I'm in favour of leaving this as it is a building the docs for the next version with matplotlib v2.