Why are these plots different?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Why are these plots different?

henryekene
Hello, Matplotlib Users,

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

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Why are these plots different?

Bruno Pagani
Hi,

Le 09/08/2019 à 16:54, Henry Ekene a écrit :
Hello, Matplotlib Users,

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.

Regards,
Bruno


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Why are these plots different?

Benjamin Root
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.

Cheers!
Ben Root


On Fri, Aug 9, 2019 at 11:07 AM Bruno Pagani <[hidden email]> 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 
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.

Regards,
Bruno

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Why are these plots different?

Elan Ernest
In reply to this post by henryekene

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.

For more, check

* the colormaps tutorial (https://matplotlib.org/3.1.1/tutorials/colors/colormaps.html),

* the API change note (https://matplotlib.org/users/dflt_style_changes.html?highlight=jet%20viridis#colormap),

* this stackoverflow question https://stats.stackexchange.com/questions/223315/why-use-colormap-viridis-over-jet

Am 09.08.2019 um 16:54 schrieb Henry Ekene:
Hello, Matplotlib Users,

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

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Why are these plots different?

henryekene
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.

God bless you all!
Henry

On 8/9/19, Elan Ernest <[hidden email]> wrote:

> 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.
>
> For more, check
>
> * the colormaps tutorial
> (https://matplotlib.org/3.1.1/tutorials/colors/colormaps.html),
>
> * the API change note
> (https://matplotlib.org/users/dflt_style_changes.html?highlight=jet%20viridis#colormap),
>
> * this stackoverflow question
> https://stats.stackexchange.com/questions/223315/why-use-colormap-viridis-over-jet
>
>
>
> Am 09.08.2019 um 16:54 schrieb Henry Ekene:
>> Hello, Matplotlib Users,
>>
>> 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
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> [hidden email]
>> https://mail.python.org/mailman/listinfo/matplotlib-users
>
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users