热线电话:13121318867

登录
2020-05-24 阅读量: 521
如何使用plt.plot画图?

plt.plot() 参数介绍:

x, y : array-like or scalar

The horizontal / vertical coordinates of the data points. x values are optional. If not given, they default to [0, …, N-1]. x是可选的,如果x没有,将默认是从0到n-1,也就是y的索引。那么我的问题就解决了。

fmt : str, optional

A format string, e.g. ‘ro’ for red circles. See the Notes section for a full description of the format strings.定义线条的颜色和样式的操作,如“ro”就是红色的圆圈。

Format strings are just an abbreviation for quickly setting basic line properties. All of these and more can also be controlled by keyword arguments. 这是一个快速设置样式的方法,更多的参数可以参考最后一个keyboard arguments。

**kwargs : Line2D properties, optional

kwargs are used to specify properties like a line label (for auto legends), linewidth, antialiasing, marker face color.这是一大堆可选内容,可以来里面指定很多内容,如“label”指定线条的标签,“linewidth”指定线条的宽度,等等

比如:

import matplotlib.pyplot as plt

x = [1, 2, 3, 4]
y = [1, 2, 20, 50]
# 创建一个画布
plt.figure()
# 创建一条线
plt.plot(x, y)

# 展现画布
plt.show()

18.5666
3
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子