问题相关代码,请勿粘贴截图
首先粘贴代码
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")
没报错的话应该会出现一个有一条曲线,三条竖直线的图
报错与hold有关
这要怎么改啊,求帮忙