Skip to content

Instantly share code, notes, and snippets.

@corvofeng
Created May 5, 2019 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corvofeng/4a43ae62717427ac07ef20776764823c to your computer and use it in GitHub Desktop.
Save corvofeng/4a43ae62717427ac07ef20776764823c to your computer and use it in GitHub Desktop.
Python使用matplotlib画图时显示中文
import matplotlib.pyplot as plt
import numpy as np
import math
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
x = np.arange(0, 10, 0.1)
y = 2**x
plt.title("指数函数")
plt.plot(x, y)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment