font.family:Error in <font name>

Asked 1 years ago, Updated 1 years ago, 74 views

I'm a beginner.
I want to solve the problem of using matplotlib to create graphs in jupyter notebook, so I am working on a mac using this site as a reference.

 font.family:Hiragino Sans

Even if you type

SyntaxError: invalid syntax

The error occurs…

The site also says that font.family:<fontname> is not quoted, so I honestly don't know what's wrong.

If you know how to solve this problem, please let me know.
Thank you for your cooperation.

python python3 matplotlib jupyter-notebook

2022-09-30 14:56

1 Answers

In the jupyter notebook, the home directory is open first, but
So I was creating a new Python file...

From the home directory (in the jupyter notebook), open ./matplotlib/matplotlibrc, where you open a new Python file.
And first of all,

 pip install japanize-matplotlib

Install the package on the .
Next is

import matplotlib.pyplot as plt
import japanize_matplotlib

When I typed it, the font family became IPAexGothic!
As a trial,

import matplotlib as mpl
print(mpl.rcParams['font.family'])

I checked it in and found out that

 ['IPAexGothic']

It came out!

(Maybe in the matplotlibrc file,
ipaexg.ttf
ipaexm.ttf
Maybe it was because there were two folders
*This font file was referenced in here).

So far, I have succeeded in changing the font family in the jupyter notebook!!
Thank you!


2022-09-30 14:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.