[PYTHON] Change the style of matplotlib

I want to make a cool plot with Matplotlib

The seaborn plot is cool. I thought it was annoying to import every time, but I realized that I could use the seaborn style without importing ** seaborn **. (Maybe it's natural?) Of course, you need to have seaborn installed in advance. Make a note of what kind of plot you can make.

Check what style you have

The style file is xxx.mplstyle in the folder matplotlib / mpl-data / stylelib. Of course you can also make it yourself. After all, each style has its advantages and disadvantages, so it may be best to make it yourself.

Content example: dark_background.mplstyle


 Set black background default line colors to white.

lines.color: white
patch.edgecolor: white

text.color: white

axes.facecolor: black
axes.edgecolor: white
axes.labelcolor: white
axes.prop_cycle: cycler('color', ['8dd3c7', 'feffb3', 'bfbbd9', 'fa8174', '81b1d2', 'fdb462', 'b3de69', 'bc82bd', 'ccebc4', 'ffed6f'])

xtick.color: white
ytick.color: white

grid.color: white

figure.facecolor: black
figure.edgecolor: black

savefig.facecolor: black
savefig.edgecolor: black

It seems good to choose the style you want to base on and play around with it yourself.

Examples

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
def testplot():
    x=np.arange(21)
    for i in range(2,9):
        y=i*0.3*np.sin(np.pi/10*x)
        plt.plot(x,y,'o-',label=str(i-1))
    
    plt.legend()
    plt.show()

####Plt to put the spell you did here.style.use()####
testplot()

Default

When you don't cast any spells. image

plt.style.use('default') For some reason, unlike the default, it's confusing. And the same result as plt.style.use ('classic').

image

plt.style.use('bmh') image

plt.style.use('dark_background') image

plt.style.use('fivethirtyeight') image

plt.style.use('ggplot') image

plt.style.use('grayscale') This is probably the style originally included in matplotlib. image

plt.style.use('seaborn-bright') image

plt.style.use('seaborn-colorblind') image

plt.style.use('seaborn-dark') image

plt.style.use('seaborn-dark-palette') image

plt.style.use('seaborn-darkgrid') image

plt.style.use('seaborn-deep') image

plt.style.use('seaborn-muted') image

plt.style.use('seaborn-pastel') image

plt.style.use('seaborn-ticks') The tick is now facing out. image

plt.style.use('seaborn-white') And it's gone. image

plt.style.use('seaborn-whitegrid') image

Can be used in combination!

plt.style.use('seaborn-colorblind')
plt.style.use('seaborn-whitegrid')

image

Resize style

The frame line is gone. I prefer this one. And since the characters etc. become larger according to the size, it seems to be convenient when you want to increase the resolution. If you want to resize, it seems good to declare the resize style first. seaborn-paper<seaborn-notebook<seaborn-talk<seaborn-poster image image image image

Finally

Please let us know if you have any other recommended styles!

Recommended Posts

Change the style of matplotlib
Change the theme of Jupyter
Change the background of Ubuntu (GNOME)
Change the Python version of Homebrew
Change the suffix of django-filter / DateFromToRangeFilter
Unravel the mystery of matplotlib specgram
About the size of matplotlib points
Change the length of Python csv strings
Align the size of the colorbar with matplotlib
Change the Y-axis scale of Matplotlib to exponential notation (10 Nth power notation)
Change the order of PostgreSQL on Heroku
Change the destination batfish server of pybatfish
Change the font size of the legend in df.plot
Increase the font size of the graph with matplotlib
One liner that lists the colors of matplotlib
Change the color of Fabric errors and warnings
Automate the placement of LaTeX own style files
Put the second axis in 2dhistgram of matplotlib
The basis of graph theory with matplotlib animation
Code for checking the operation of Python Matplotlib
Visualize the behavior of the sorting algorithm with matplotlib
Change the resolution of Ubuntu running on VirtualBox
The beginning of cif2cell
The meaning of self
the zen of Python
The story of sys.path.append ()
Installation of matplotlib (Python 3.3.2)
Revenge of the Types: Revenge of types
[Touch Designer] Change the appearance color of Button COMP
Add information to the bottom of the figure with Matplotlib
Omit the decimal point of the graph scale in matplotlib
[Django] Change the Default IP address of the runserver command
[Introduction to Python] Basic usage of the library matplotlib
Adjust the ratio of multiple figures with the matplotlib gridspec
[Python] Let's change the URL of the Django administrator site
Align the version of chromedriver_binary
[Python] Change the Cache-Control of the object uploaded to Cloud Storage
10. Counting the number of lines
The story of building Zabbix 4.4
Towards the retirement of Python2
About the camera change event of Google Maps Android API
[Apache] The story of prefork
Japanese display of matplotlib, seaborn
The road to download Matplotlib
Compare the fonts of jupyter-themes
behavior of matplotlib: histogram normed
About the ease of Python
Get the number of digits
Explain the code of Tensorflow_in_ROS
Reformat the timeline of the pandas time series plot with matplotlib
Reuse the results of clustering
Change the log retention period of CloudWatch Logs in Lambda
Calculate the number of changes
Change the volume of Pepper according to the surrounding environment (sound)
The popularity of programming languages
Visualize the orbit of Hayabusa2
About the components of Luigi
Connected components of the graph
Filter the output of tracemalloc
About the features of Python
I wrote the basic operation of matplotlib with Jupyter Lab