【发布时间】:2020-08-13 08:49:44
【问题描述】:
我试图在matplotlib 中使用setp 将刺的可见性设置为False,但我收到错误“AttributeError: 'str' object has no attribute 'update'”。
据我了解,使用setp我们可以更改可迭代对象的属性,并希望使用spines执行它。
有效使用setp的正确语法是什么?
找一个 MWE:
import matplotlib.pyplot as plt
x = range(0,10)
y = [i*i for i in x]
plt.plot(x,y) #Plotting x against y
axes = plt.gca() #Getting the current axis
axes.spines['top'].set_visible(False) #It works
plt.setp(axes.spines, visible=False) #It rises error
plt.show() #Showing the plot
版本: python3.8.2、Matplotlib 3.2.1
【问题讨论】:
标签: python-3.x matplotlib plot axes