Python matplotlib Line2D对象怎么用
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,这篇文章主要介绍 Python matplotlib Line2D对象怎么用,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!总括matplotlib.pyplot很像MATLAB
千家信息网最后更新 2025年12月02日Python matplotlib Line2D对象怎么用
这篇文章主要介绍 Python matplotlib Line2D对象怎么用,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
总括
matplotlib.pyplot很像MATLAB。它的每一个函数都会对现有的图形进行更改:比如建立一个图形(figure),创建画图区域,在画图区域做出线条,使用标签装饰。
如果你传入了一个简单的list或者array,matplotlib会把它当成y值,并自动生成x值。事实上所有序列都会被转换为numpy arrays。
import matplotlib.pyplot as pltplt.plot([1,2,3,4])plt.ylabel('some numbers')plt.show()当你传入两个list或者array时,第一个会被当成x值,第二个会被当成y值,而且你可以通过第三个参数设置显示的形状和颜色(这是一个组合),当然你也可以分别设置形状和颜色。通过plt.axis(xmin, xmax, ymin, ymax)函数你可以设置x轴,y轴的最大值和最小值:
import matplotlib.pyplot as pltplt.plot([1,2,3,4], [1,4,9,16], 'ro')plt.axis([0, 6, 0, 20])plt.show()
Line2D对象
Line2D
Bases: matplotlib.artist.Artistclass 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)
属性控制
有三种方式设置线的属性
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 argsplt.setp(lines, color='r', linewidth=2.0)
| Property | Value Type |
|---|---|
| alpha | float |
| animated | [True False] |
| antialiased or aa | [True False] |
| clip_box | a matplotlib.transform.Bbox instance |
| clip_on | [True False] |
| clip_path | a Path instance and a Transform instance, a Patch |
| color or c | any matplotlib color |
| contains | the hit testing function |
| dash_capstyle | ['butt' 'round' 'projecting'] |
| dash_joinstyle | ['miter' 'round' 'bevel'] |
| dashes | sequence of on/off ink in points |
| data | (np.array xdata, np.array ydata) |
| figure | a matplotlib.figure.Figure instance |
| label | any string |
| linestyle or ls | ['-' '-' '-.' ':' 'steps' …] |
| linewidth or lw | float value in points |
| lod | [True False] |
| marker | ['+' ',' '.' '1' '2' '3' '4'] |
| markeredgecolor or mec | any matplotlib color |
| markeredgewidth or mew | float value in points |
| markerfacecolor or mfc | any matplotlib color |
| markersize or ms | float |
| markevery | [ None integer (startind, stride) ] |
| picker | used in interactive line selection |
| pickradius | the line pick selection radius |
| solid_capstyle | ['butt' 'round' 'projecting'] |
| solid_joinstyle | ['miter' 'round' 'bevel'] |
| transform | a matplotlib.transforms.Transform instance |
| visible | [True False] |
| xdata | np.array |
| ydata | np.array |
| zorder | any number |
| linestyle | description |
|---|---|
| '-'?or?'solid' | solid line |
| '-'?or?'dashed' | dashed line |
| '-.'?or?'dashdot' | dash-dotted line |
| ':'?or?'dotted' | dotted line |
| 'None' | draw nothing |
| '?' | draw nothing |
| " | draw nothing |
| marker | description |
|---|---|
| "." | point |
| "," | pixel |
| "o" | circle |
| "v" | triangle_down |
| "^" | triangle_up |
| "<" | triangle_left |
| ">" | triangle_right |
| "1" | tri_down |
| "2" | tri_up |
| "3" | tri_left |
| "4" | tri_right |
| "8" | octagon |
| "s" | square |
| "p" | pentagon |
| "P" | plus (filled) |
| "*" | star |
| "h" | hexagon1 |
| "H" | hexagon2 |
| "+" | plus |
| "x" | x |
| "X" | x (filled) |
| "D" | diamond |
| "d" | thin_diamond |
| " | " |
| "_" | hline |
| TICKLEFT | tickleft |
| TICKRIGHT | tickright |
| TICKUP | tickup |
| TICKDOWN | tickdown |
| CARETLEFT | caretleft (centered at tip) |
| CARETRIGHT | caretright (centered at tip) |
| CARETUP | caretup (centered at tip) |
| CARETDOWN | caretdown (centered at tip) |
| CARETLEFTBASE | caretleft (centered at base) |
| CARETRIGHTBASE | caretright (centered at base) |
| CARETUPBASE | caretup (centered at base) |
| "None",?"?"?or?"" | nothing |
| ' ... ' | render the string using mathtext. |
| verts | a list of (x, y) pairs used for Path vertices. The center of the marker is located at (0,0) and the size is normalized. |
| path | a?Path?instance. |
以上是" Python matplotlib Line2D对象怎么用"这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!
对象
函数
属性
内容
区域
图形
形状
篇文章
颜色
最大
最小
三个
两个
事实
事实上
价值
兴趣
参数
可以通过
小伙
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
智慧管理体系属于软件开发吗
小学观看网络安全报道
山东gis软件开发
邯郸市网络安全知识竞赛名单
服务器缓存盘有什么作用
关于网络安全微信对话
暗黑2韩国服务器
车辆识别软件提示数据库连接失败
涉及海量数据库的案例
数据库数据分类方法
啥叫数据库访问技术
福州软件开发企业
山东自动炒币机器人软件开发价格
oracle数据库例题
福州优易通网络技术有限公司
阿里云服务器在线客服
软件开发事业部是干嘛的
交易型数据库 分析型
网络安全你我他手抄报五年级
服务器运营顾问
阿里数据库设计
软件开发实战
沽源县网络安全培训学校
重庆网站服务器租用云主机
软件开发回购协议
华为独立软件开发合作伙伴
提取数据库密码
火元素网络技术公司招聘
广东恒邦网络技术有限公司
在线红外数据库