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

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 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示