xlabel
、ylabel
: 设置横轴、纵轴标签及大小
例如plt.xlabel("csdn test", fontsize=20)
xlim
、ylim
: 设置x、y坐标轴的起始点(从哪到哪)
例如plt.xlim(0,50)
plt.ylim(0,60)
xticks
、yticks
: 设置坐标轴刻度的字体大小
例如plt.xticks(labelsize=20)
title
: 设置图片的标题
例如plt.title(“csdn test”)
plt.figure()
: 制一个新画布;
该函数中比较重要的参数:figsize
:指定figure的宽和高(用法:figsize=(5,5)
);
dpi
:指定绘图对象的分辨率;
facecolor
:背景颜色(用法:facecolor=‘blue’
)plt.legend():
添加图例(如下图)。有handles
、labels
和loc
三个参数
handles
需要传入你所画线条的实例对象(见下面的参考例子)
labels
是图例的名称(能够覆盖在plt.plot( )
中label
参数值,如果plt.plot
中指定了label
参数,就不需要plt.legend
画图例了)
loc
代表了图例在整个坐标轴平面中的位置(一般选取'best'
这个参数值)l1, = plt.plot(x,y1,color='red',linewidth
matplotlib常见绘图函数
最新推荐文章于 2025-02-06 20:13:11 发布