Draw a graph with Japanese labels in Jupyter

IPython Notebook, in the default state, the Japanese label in the graph becomes tofu, so I think that many people use it by specifying the Japanese font in the configuration file. However, after updating IPython to 3, the IPython Notebook became Jupyter, and Japanese became tofu again.

Apparently, the configuration of the configuration file has changed, so I can no longer use the existing Profile. ʻIpython_ * _ config.py` The default contents of the file with the same name as the existing one have changed, so it seems better to recreate each profile.

Jupyter config file

In IPython 3.x series, it seems that IPython 2.x series ʻipython_notebook_config.py is divided into ʻipython_kernel_config.py and ʻipython_notebook_config.py`.

If you want to use Japanese labels in Matplotlib, you need to write them in ʻipython_kernel_config.py`.

ipython_kernel_config.py


c.InlineBackend.rc = {
    'font.size': 11,
    'font.family': 'Osaka',
    'figure.figsize': (6.0, 4.0),
    'savefig.dpi': 80,
    'axes.titlesize': 12
}

c.InlineBackend.figure_formats = set(['png', 'retina'])

Now you can use Japanese labels.

スクリーンショット 2015-03-08 23.29.49.png

Check the set value

On Jupyter

import matplotlib
matplotlib.rcParams.get('font.family')

The list of available fonts is

import matplotlib.font_manager as fm
fm.findSystemFonts()

Obtained at.

Recommended Posts

Draw a graph with Japanese labels in Jupyter
Draw a graph with NetworkX
Draw a graph with networkx
Draw a graph with Julia + PyQtGraph (2)
Draw a loose graph with matplotlib
Draw a graph with Julia + PyQtGraph (1)
Draw a graph with Julia + PyQtGraph (3)
Draw a graph with pandas + XlsxWriter
Draw a graph with PySimple GUI
Draw a heart in Ruby with PyCall
Draw a graph with PyQtGraph Part 1-Drawing
Draw a flat surface with a matplotlib 3d graph
Draw a graph of a quadratic function in Python
How to draw a 2-axis graph with pyplot
Draw a "breast curved surface" in a 3D graph (1)
(Matplotlib) I want to draw a graph with a size specified in pixels
Draw a graph with PyQtGraph Part 3-PlotWidget settings
Draw a graph by processing with Pandas groupby
[Python] Draw a directed graph with Dash Cytoscape
Draw a graph with PyQtGraph Part 4-PlotItem settings
Draw a graph with matplotlib from a csv file
Draw a graph with PyQtGraph Part 6-Displaying a legend
Draw a "breast curved surface" in a 3D graph (2)
Draw graph in python
Draw multiple photos in a graph from multiple folders
Draw a graph with PyQtGraph Part 5-Increase the Y-axis
Draw a graph in Julia ... I tried a little analysis
[Python] How to draw a line graph with Matplotlib
Drawing a tree structure with D3.js in Jupyter Notebook
Draw a graph with PyQtGraph Part 2--Detailed plot settings
Draw a heart in Python
Create SVG graph with matplotlib on heroku (displayed in Japanese)
[Visualization] I want to draw a beautiful graph with Plotly
Make a sound with Jupyter notebook
Draw Japanese with matplotlib on Ubuntu
Draw a scatterplot matrix in python
Draw a beautiful circle with numpy
Draw retention rate graph in Matplotlib
Let's make a graph with python! !!
Draw a CNN diagram in Python
Make a nice graph with plotly
Easily draw a map with matplotlib.basemap
Draw a watercolor illusion with edge detection in Python3 and openCV3
Spiral book in Python! Python with a spiral book! (Chapter 14 ~)
[Small story] How to save matplotlib graphs in a batch with Jupyter
[PyQt] Display a multi-axis graph with QtChart
How to draw a graph using Matplotlib
Draw Nozomi Sasaki in Excel with python
Put Japanese fonts in images with Colaboratory
Draw a heart in Python Part 2 (SymPy)
Draw a Mandelbrot set with Brainf * ck
How to draw a bar graph that summarizes multiple series with matplotlib
Draw a graph that can be moved around with HoloViews and Bokeh
Draw hierarchical axis labels with matplotlib + pandas
Draw a tree in Python 3 using graphviz
Simply draw a graph by specifying a file
Create a graph with borders removed with matplotlib
To output a value even in the middle of a cell with Jupyter Notebook
Get the stock price of a Japanese company with Python and make a graph
[Python] Get the files in a folder with Python
Speaking Japanese with OpenJtalk (reading a text file)