Python matplotlib 线图(plt.plot())

http://matplotlib.org/api/lines_api.html#matplotlib.lines.Line2D

线图

生成线图对象Line2D

Bases: matplotlib.artist.Artist
class matplotlib.lines.Line2D(xdata, ydata, linewidth=None, linestyle=None, color=None, marker=None, markersize=None, markeredgewidth=None, markeredgecolor=None, markerfacecolor=None, markerfacecoloralt='none', fillstyle=None, antialiased=None, dash_capstyle=None, solid_capstyle=None, dash_joinstyle=None, solid_joinstyle=None, pickradius=5, drawstyle=None, markevery=None, **kwargs)

plt.plot()参数设置

PropertyValue Type
alpha控制透明度,0为完全透明,1为不透明
animated[True False]
antialiased or aa[True False]
clip_boxa matplotlib.transform.Bbox instance
clip_on[True False]
clip_patha Path instance and a Transform instance, a Patch
color or c颜色设置
containsthe hit testing function
dash_capstyle[‘butt’ ‘round’ ‘projecting’]
dash_joinstyle[‘miter’ ‘round’ ‘bevel’]
dashessequence of on/off ink in points
data数据(np.array xdata, np.array ydata)
figure画板对象a matplotlib.figure.Figure instance
label图示
linestyle or ls线型风格[‘-’ ‘–’ ‘-.’ ‘:’ ‘steps’ …]
linewidth or lw宽度float value in points
lod[True False]
marker数据点的设置[‘+’ ‘,’ ‘.’ ‘1’ ‘2’ ‘3’ ‘4’]
markeredgecolor or mecany matplotlib color
markeredgewidth or mewfloat value in points
markerfacecolor or mfcany matplotlib color
markersize or msfloat
markevery[ None integer (startind, stride) ]
pickerused in interactive line selection
pickradiusthe line pick selection radius
solid_capstyle[‘butt’ ‘round’ ‘projecting’]
solid_joinstyle[‘miter’ ‘round’ ‘bevel’]
transforma matplotlib.transforms.Transform instance
visible[True False]
xdatanp.array
ydatanp.array
zorderany number

属性控制

有三种方式设置线的属性
1)直接在plot()函数中设置

plt.plot(x, y, linewidth=2.0)

2)通过获得线对象,对线对象进行设置

line, = plt.plot(x, y, '-')
line.set_antialiased(False) # turn off antialising

3)获得线属性,使用setp()函数设置

lines = plt.plot(x1, y1, x2, y2)
# use keyword args
plt.setp(lines, color='r', linewidth=2.0)

其他

Matplotlib 颜色样式快捷设置

一个应用,在图上做一条垂直于x轴的线段,要用两个相同x,不同y的点来刻画
plt.plot([x,x],[0,y])

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值