axhline函数--Matplotlib
axhline函数使用–Matplotlib
该函数用法可平移至axvline上
函数功能: Add a horizontal line across the axis.
在轴上添加一条水平线
函数语法: axhline(y=0, xmin=0, xmax=1, **kwargs)
函数参数:
y: float, default: 0 ;y position in data coordinates of the horizontal line.
浮点型,默认值0,水平线在坐标中y点的位置
xmin: float, default: 0 ;Should be between 0 and 1, 0 being the far left of the plot, 1 the far right of the plot.
浮点型,默认值为0,取值位于[0,1]之间,取值0时在图的左边界,取值1时在图的右边界。
xmax: float, default: 1;Should be between 0 and 1, 0 being the far left of the plot, 1 the far right of the plot.
浮点型,默认值为1,取值位于[0,1]之间,0取值时在图的左边界,取值1时在图的右边界。
上面两个参数xmin,xmax指定水平线的起始位置与结束位置
**kwargs: 其他关键参数,如:水平线的颜色、风格、粗细等
无参数传入:默认在y=0的位置,从最左侧(0)到最右侧(1),实线绘制
绘制y = 0.6
则xmin取值为[0,1],绘制范围为边右边界值*xmin,如本图中:xmin=0.2,xmax=0.8表示绘制水平线的范围为10∗0.210*0.210∗0.2~10∗0.810*0.810∗0.8之间
其他参数:如设置水平线的粗细,风格,颜色
axvline函数
函数功能: Add a vertical line across the axes.
在轴上添加一条垂直线
函数语法: axhline(x=0, xmin=0, ymax=1, **kwargs)
函数参数:
x: float, default: 0 ;x position in data coordinates of the vertical line.
浮点型,默认值0,垂直线在坐标中x点的位置
ymin: float, default: 0 ;Should be between 0 and 1, 0 being the bottom of the plot, 1 the top of the plot.
浮点型,默认值为0,取值位于[0,1]之间,取值0时在图的下边界,取值1时在图的上边界。
ymax: float, default: 1;Should be between 0 and 1, 0 being the bottom of the plot, 1 the top of the plot.
浮点型,默认值为1,取值位于[0,1]之间,取值0时在图的下边界,取值1时在图的上边界。
上面两个参数ymin,ymax指定垂直线的起始位置与结束位置
**kwargs: 其他关键参数,如:水平线的颜色、风格、粗细等
具体相关信息可参看上面的axhline
import matplotlib.pyplot as plt
import numpy as npx = np.linspace(0.05, 10, 1000)
y = np.sin(x)plt.plot(x, y,ls = '-.',lw = 2,c='c',label = 'plot figure')plt.legend(loc = 'lower left') # 设定图例位置plt.grid() #绘制网格线plt.xlim(0,10) #调整x轴边界plt.axhline(y = 0.6,xmin = 0.2,xmax = 0.8, c = 'r',ls = '--',lw = 1) #绘制平行于x轴的水平线
plt.axvline(x = 5,ymin = 0.2,ymax = 0.8, c = 'g',ls = '-',lw = 3) #绘制平行于y轴的垂直线
plt.show()
axhline函数--Matplotlib相关推荐
- python matplotlib pyplot plt.axhline()函数(绘制平行于x轴的水平参考线)
函数功能:绘制平行于x轴的水平参考线调用签名:plt.axhline(y=0.0, c="r", ls="--", lw=2)y:水平参考线的出发点c:参考线的 ...
- 魔法函数%matplotlib 解决matplotlib画图在Jupter/IPython中不显示
用Python画图时,有时候画图结果存储在内存中不显示,如下图 import seaborn as sns subset = tz_counts[:10] sns.barplot(y=subset.i ...
- python可视化---axhline()函数
函数功能:绘制平行于x轴的水平参考线 调用签名:plt.axhline(y=0.0, c="r", ls="--", lw=2) y:水平参考线的出发点 c:参 ...
- 【Python】可视化---axhline()函数
一.函数功能:绘制平行于x轴的水平参考线 二.语法:plt.axhline(y=0.0, c="r", ls="–", lw=2) 三.参数解读: y:水平参考 ...
- subplots_adjust()函数--matplotlib
1. 函数功能 调整子区的展现效果 2. 函数语法 subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, ...
- setp函数--Matplotlib
函数功能: Set a property on an artist object. 设置元素属性 函数语法: setp(obj, *args, **kwargs) 函数参数: obj: 要设置的对象 ...
- xlabel函数--Matplotlib
xlabel函数使用–Matplotlib xlabel语法.功能与参数设置可平移至ylabel. 函数语法: xlabel(xlabel, fontdict=None, labelpad=None, ...
- annotate()函数--matplotlib
1. 函数功能 对点(x,y)添加带箭头的注释文本. 2. 函数语法 Axes.annotate(text, xy, xytext=None, xycoords='data', textcoords= ...
- 系统学习Python——2D绘图库Matplotlib:绘图函数matplotlib.pyplot.plot(plt.plot)
分类目录:<系统学习Python>总目录 matplotlib.pyplot是Matplotlib的基于状态的接口.它提供了一种隐式的.类似MATLAB的绘图方式.它还会在您的屏幕上打开图 ...
- python 绘制正弦余弦函数 matplotlib的基本使用
"""matplotlib的基本使用 """ import matplotlib.pyplot as mp import numpy as ...
最新文章
- vue打包后图片找不到情况
- python有证书考吗-学python需要考证吗?
- python基础知识ppt-python入门ppt下载
- 【uniapp】 下拉刷新页面
- VS2010 无法计算HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0@VCTargetPath处的属性表达式...
- java get和post区别_HTTP请求方式GET和POST区别
- Xray使用的一些经验分享(xray+burp的使用)
- Git 操作总结整合篇
- linux转发邮件,转发Linux服务器上的传入邮件?
- mysql language sql immutable_sql - PostgreSQL是否支持“不区分重音”排序规则?
- 基于Unity的极乐净土/others MMD动画制作
- link.html百度云,网盘链接自取
- Node.js 服务端图片处理利器——sharp 进阶操作指南
- 使用Python把BT种子转化为磁力链接
- html图片边框的颜色,css图片的边框怎么设置颜色?
- 大图片显示在客户端,被压扁失真的问题
- 微信小程序共享元素+ page-container假页实现弹出效果
- SAP MM移动平均价和标准价逻辑
- elasticsearch集群管理插件之cerebro安装配置
- PhotoShop算法实现进阶-浮雕滤镜-灰度浮雕(三十一)
热门文章
- unity设置一个物体是另一个物体的子物体
- Atitit 粘贴路径参数法 跨进程通讯法 目录 1. .IPC(Inter-Process Communication,跨进程通信)	1 1.1. .IPC的使用场景:	2 2. 传统的进程间通
- Atitit mybatis 配置 redis 集成 attilax总结 艾提拉总结 1.1. setting name=cacheEnabled v	1 1.2. Mapper文件	1 1.
- Atitit 网络编程之道
- Atitit.Gui按钮与面板---项目规模的评估----文件数统计,结构,代码行数,每类型文件行数.
- paip.sql2k,sql2005,sql2008,sql2008 r2,SQL2012以及EXPRESS版本的区别
- PAIP.提升安全性----COOKIE绑定IP与城市与运营商
- 锻造恒生O45:致广大而尽精微
- 范华:资产配置是非常客户化的过程
- (转)全球最神秘的高频交易巨头Jump Trading