My challenge is that I saw this below image somewhere
Screenshot from 2019-08-09 15-24-34.pngand i decided to reproduce it
using the same matplotlib codes but it turned out that my own image
appear different as can be seen below
Screenshot from 2019-08-09 15-28-38.pngPlease why is mine different in
color, and what can I do to get the exact image as the other one?
Thanks for your help.
Henry
You use a different version of matplotib than whoever made the first
one. Lots of things have changed regarding defaults, including colormap.
You are using the “new” viridis colormap, the plot above looks like jet.
This is not the only difference between the two plots (look at e.g.
ticks direction, spine…). To reproduce the old plot, the easiest would
be to use the classic stylesheet of matplotlib with
`plt.style.use("classic")`, to be added after importing matplotlib.
Indeed, this is the reason. Please note that there is a reason why the Jet colormap is no longer our default colormap. We aren’t the only plotting system to drop Jet as the default colormap (matlab and some others switch away from it). Notice in the original image, the colormap would lead the viewer to believe that the gradients are larger than they actually are. This effect has been shown in studies to lead to incorrect conclusions about the data (particularly leading to incorrect medical diagnosis!). The viridis colormap, which has been matplotlib’s default for a few years now, is considered to be among most “perceptually uniform” colormap out there.
On Fri, Aug 9, 2019 at 11:07 AM Bruno Pagani [email protected] wrote:
Hi,
Le 09/08/2019 à 16:54, Henry Ekene a
écrit :
Hello, Matplotlib Users,
My challenge is that I saw this below image somewhere
and i decided to reproduce it using
the same matplotlib codes but it turned out that my own image
appear different as can be seen below
Please why is mine different in
color, and what can I do to get the exact image as the other
one? Thanks for your help.
Henry
You use a different version of matplotib than whoever made the
first one. Lots of things have changed regarding defaults,
including colormap. You are using the “new” viridis colormap, the
plot above looks like jet.
This is not the only difference between the two plots (look at
e.g. ticks direction, spine…). To reproduce the old plot, the
easiest would be to use the classic stylesheet of matplotlib with plt.style.use("classic"), to be added after importing
matplotlib.
The first plot uses the jet colormap, the second one the viridis colormap. You can set the colormap via the cmap
argument (contourf(…, cmap=“jet”))
Note however, that we (more or less strongly) discourage the use
of the jet colormap for heatmaps like this. This plot makes up a
nice example for why: The jet colormap results in “features” being
seen in the data, which aren’t actually there.
Thank you so much! Bruno, Elan Ernest, and Ben Root, you guys are
wonderful! I added the matplotlib's "classic style" option as
suggested by Bruno, and to my surprise, it worked!
On the other hand, the "jet" colormap as an added argument, suggested
by Elan Ernest also produced what I was looking for. Meanwhile, I've
also taken note that the result produced by the "jet" colormap may be
misleading, the reason for its discontinued use as the default, as
explained by Ben and Elan.
You saved the day for me! And I've learnt a great deal from you guys.
The first plot uses the `jet` colormap, the second one the `viridis`
colormap. You can set the colormap via the `cmap` argument
(contourf(..., cmap="jet"))
Note however, that we (more or less strongly) discourage the use of the
jet colormap for heatmaps like this. This plot makes up a nice example
for why: The jet colormap results in "features" being seen in the data,
which aren't actually there.
My challenge is that I saw this below image somewhere
Screenshot from 2019-08-09 15-24-34.pngand i decided to reproduce it
using the same matplotlib codes but it turned out that my own image
appear different as can be seen below
Screenshot from 2019-08-09 15-28-38.pngPlease why is mine different in
color, and what can I do to get the exact image as the other one?
Thanks for your help.