pyplot.plot() 参数

plot函数一般的调用形式

#单条线:
plot(x, y, [fmt], data=None, **kwargs)

#多条线
plot(x, y, [fmt], x2, y2, [fmt2], ..., **kwargs)

可选参数[fmt] 是一个字符串来定义图的基本属性如:颜色(color)、点型(marker)、线型(linestyle),具体形式 fmt = '[color][marker][line]'

fmt接收的是每个属性的单个字母缩写,例如:

import matplotlib.pyplot as plt

plt.plot(x, y, 'bo-')  # 蓝色圆点实线

属性用的是全名则不能用 [fmt] 参数来组合赋值,应该用关键字参数对单个属性赋值如:

import matplotlib.pyplot as plt

plt.plot(x, y, color='green', marker='o', linestyle='dashed', linewidth=2, markersize=10)

plt.plot(x, y, color='#008000', marker='=', linestyle='-')

color 可以使用十六进制字符串("# 008000"),也可以用以下字符表示:

'b'蓝色
'g'绿色
'r'红色
'c'青色
'm'品红
'y'黄色
'k'黑色
'w'白色

marker参数可以使用以下的字符串

'-'solid line style
'--'dashed line style
'-.'dash-dot line style
':'dotted line style
'.'point marker
','pixel marker
'o'circle marker
'v'triangle_down marker
'^'triangle_up marker
'<'triangle_left marker
'>'triangle_right marker
'1'tri_down marker
'2'tri_up marker
'3'tri_left marker
'4'tri_right marker
's'square marker
'p'pentagon marker
'*'star marker
'h'hexagon1 marker
'H'hexagon2 marker
'+'plus marker
'x'x marker
'D'diamond marker
'd'thin_diamond marker
'|'vline marker
'_'hline marker

线性参数 linestyle

'-'solid  实线
'--'dashed  虚线
'-.'dash-dot  点画线
':'dotted  点线

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值