-
绘制折线图:plot([x], y, [fmt], data=None, **kwargs)
绘制多条线 :plot([x], y, [fmt], [x2], y2, [fmt2], …, **kwargs)
The coordinates of the points or line nodes are given by x, y.
fmt is a convenient way for defining basic formatting like color, marker and linestyle.
data:An object with labelled data. If given, provide the label names to
plot in x and y
**kwargs :.Line2D
properties, optional
kwargs are used to specify properties like a line label (for
auto legends), linewidth, antialiasing, marker face color.
2)绘制散点图:
scatter(x, y, s=None, c=None, marker=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None, *, data=None, **kwargs)s: 点的规格
c:颜色
cmap:颜色映射
edgecolors:删除数据点的轮廓3)绘制柱状图:
bar(x, height, width=0.8, bottom=None, *, align=‘center’, data=None, **kwargs)
align : {‘center’, ‘edge’} -
修饰
pit.title() 加标题
pit.xlabel() x轴加标签
pit.ylabel()
plt.tick_params(axis,labelsize ) 设置刻度标记的大小
axis = xlabel / ylabel / both
plt.axis([x_min, x_max, y_min, y_max]) 设置坐标轴的取值范围
plt.savefig() plt.savefig(‘work_1’, dpi=800, bbox_inches=‘tight’,format = ‘pdf’)
保存图片,名称 像素 裁剪掉多余的空白 保存的格式5) 中文显示plt.rc(‘font’, family=‘STSong’, size=14) 字体,及字号大小
plt.rc(‘axes’, unicode_minus=False)
matplotlib绘制常见统计图
最新推荐文章于 2024-05-30 09:59:22 发布