- 显示中文乱码问题
import matplotlib.pyplot as plt
# mac中
plt.rcParams['font.sans-serif']='Heiti TC'
# windows中
plt.rcParams['font.family'] = ['sans-serif']
plt.rcParams['font.sans-serif'] = ['SimHei']
# 负号正常显示
plt.rcParams['axes.unicode_minus'] = False # 负号正常显示
- 画折线图
import matplotlib.pyplot as plt
import numpy as np
x = np.array([1, 2.4, 3, 4, 5.3, 6])
y = np.array([3, 2, 5, 4.2, 4 ,7.2])
plt.plot(x,y)
- 画散点图
import matplotlib.pyplot as plt
import numpy as np
x = np.array([1, 2.4, 3, 4, 5.3, 6])
y = np.array([3, 2, 5, 4.2, 4 ,7.2])
plt.scatter(x,y)
- 坐标轴旋转(坐标是日期的时候很有用)
plt.xticks(rotation=60) # 旋转60度