Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use seaborn without changing the matplotlib defaults?

I am trying to use seaborn, because of its distplot function. But I prefer the default matplotlib settings. When I import seaborn, it changes automatically the appearance of my figure.

How can I use seaborn functions without changing the look of the plots?

like image 821
Hello lad Avatar asked Aug 19 '14 22:08

Hello lad


People also ask

Can you use Seaborn and Matplotlib together?

Seaborn is indeed an add-on to matplotlib. Therefore, you need to understand how matplotlib handles plots even if using Seaborn. Matplotlib calls its canvas the figure. You can divide the figure into several sections called subplots, so you can put two visualizations side-by-side.

How do I change from Matplotlib to Seaborn?

To switch to seaborn defaults, simply call the set_theme() function. (Note that in versions of seaborn prior to 0.8, set_theme() was called on import. On later versions, it must be explicitly invoked). Seaborn splits matplotlib parameters into two independent groups.

Do you need Matplotlib to use Seaborn?

Seaborn is a high-level library. It provides simple codes to visualize complex statistical plots, which also happen to be aesthetically pleasing. But Seaborn was built on top of Matplotlib, meaning it can be further powered up with Matplotlib functionalities.

Is Seaborn an extension of Matplotlib?

Seaborn is one of the world's most regarded Python libraries that is purpose-built to create beautiful-looking visualizations. It can be considered as an extension of another library called Matplotlib as it is built on top of that.


1 Answers

Version 0.8 (july 2017) changed this behaviour. From https://seaborn.pydata.org/whatsnew.html#v0-8-0-july-2017:

The default (seaborn) style is no longer applied when seaborn is imported. It is now necessary to explicitly call set() or one or more of set_style(), set_context(), and set_palette(). Correspondingly, the seaborn.apionly module has been deprecated.

For older versions, Import seaborn like this:

import seaborn.apionly as sns 

and then you should be able to use sns.distplot but maintain the default matplotlib styling + your personal rc configuration.

like image 59
mwaskom Avatar answered Sep 19 '22 17:09

mwaskom