0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Google Colabで日本語対応する

Posted at

はじめに

Google Colabを利用するとグラフにタイトルを出した場合、文字化けします。
なかなか解決方法が書いてなかったので、書いておきます。

成果物

image.png

!apt-get -y install fonts-ipafont-gothic
!pip install japanize-matplotlib
import japanize_matplotlib
import matplotlib.pyplot as plt

# 場合によっては必要
plt.rcParams['font.family'] = 'IPAPGothic'
japanize_matplotlib.japanize()

# グラフを描いて日本語確認
plt.figure(figsize=(6, 4))
plt.plot([60, 70, 80], [1, 2, 3])
plt.title("数学の点数推移")  # 日本語が出るかチェック
plt.xlabel("点数")
plt.ylabel("回数")
plt.grid(True)
plt.show()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?