plt

2021-03-25  本文已影响0人  CCB孑孓

函数

figure()

plt.figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True)
'''
     num  : 图像编号或名称,数字为编号,字符串为名称
  figsize : 指定figure的宽和高,单位为英寸
      dpi : 指定绘图对象的分辨率,即每英寸多少个像素,缺省值为80
facecolor : 背景的颜色
edgecolor : 边框颜色
  frameon : 是否显示边框
'''
import pandas as pd
import matplotlib.pyplot as plt

fig = plt.figure(num=321, figsize=(2, 3))
data = {
    'apples': [3, 2, 0, 1],
    'oranges': [0, 3, 7, 2]
}
df = pd.DataFrame(data)
plt.plot(df)
plt.show()

背景色设置成功了,但是很丑,边框设置之后并没有看出来有边框的样子

xticks()

plt.xticks(x, label, rotation='vertical')
'''
    x : 坐标轴X或Y
   label : 标签列表,len(label) >= len(x)
rotation : 标签垂直
'''
import matplotlib.pyplot as plt

fig = plt.figure(num=321, figsize=(2, 3))
x = [0, 1, 2, 3]
y = [0, 3, 7, 2]
label = ['red', 'blue', 'green', 'yellow']
plt.plot(x, y)
plt.xticks(x, label, rotation='vertical')
plt.show()
上一篇 下一篇

猜你喜欢

热点阅读