chealsea11 2022-03-27 18:40 采纳率: 100%
浏览 1745
已结题

python错误类型 :AttributeError: 'Line2D' object has no property 'hold'

问题相关代码,请勿粘贴截图

首先粘贴代码

plt.axvline(med,color='g',hold=None,linestyle='--',alpha=0.8)
plt.text(mean+5,0.015,'中位数:%i'%med,color='g')


错误类型

AttributeError                            Traceback (most recent call last)
<ipython-input-174-ed5ef390ce6e> in <module>
     10 med=data['value'].median()
     11 print('中位数为%i'%med)
---> 12 plt.axvline(med,color='g',hold=None,linestyle='--',alpha=0.8)
     13 plt.text(mean+5,0.015,'中位数:%i'%med,color='g')

~\anaconda3\lib\site-packages\matplotlib\pyplot.py in axvline(x, ymin, ymax, **kwargs)
   2471 @_copy_docstring_and_deprecators(Axes.axvline)
   2472 def axvline(x=0, ymin=0, ymax=1, **kwargs):
-> 2473     return gca().axvline(x=x, ymin=ymin, ymax=ymax, **kwargs)
   2474 
   2475 

~\anaconda3\lib\site-packages\matplotlib\axes\_axes.py in axvline(self, x, ymin, ymax, **kwargs)
    914 
    915         trans = self.get_xaxis_transform(which='grid')
--> 916         l = mlines.Line2D([x, x], [ymin, ymax], transform=trans, **kwargs)
    917         self.add_line(l)
    918         self._request_autoscale_view(scalex=scalex, scaley=False)

~\anaconda3\lib\site-packages\matplotlib\lines.py in __init__(self, xdata, ydata, linewidth, linestyle, color, marker, markersize, markeredgewidth, markeredgecolor, markerfacecolor, markerfacecoloralt, fillstyle, antialiased, dash_capstyle, solid_capstyle, dash_joinstyle, solid_joinstyle, pickradius, drawstyle, markevery, **kwargs)
    388         # update kwargs before updating data to give the caller a
    389         # chance to init axes (and hence unit support)
--> 390         self.update(kwargs)
    391         self.pickradius = pickradius
    392         self.ind_offset = 0

~\anaconda3\lib\site-packages\matplotlib\artist.py in update(self, props)
    994                     func = getattr(self, f"set_{k}", None)
    995                     if not callable(func):
--> 996                         raise AttributeError(f"{type(self).__name__!r} object "
    997                                              f"has no property {k!r}")
    998                     ret.append(func(v))

AttributeError: 'Line2D' object has no property 'hold'


![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/549303773846191.png "#left")

![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/520992773846154.png "#left")


img

没报错的话应该会出现一个有一条曲线,三条竖直线的图
报错与hold有关
这要怎么改啊,求帮忙

  • 写回答

3条回答 默认 最新

查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 4月4日
  • 已采纳回答 3月27日
  • 创建了问题 3月27日

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献