Skip to main content
 首页 » 编程设计

python之APLpy 错误 : 'Colorbar' object has no attribute 'set_axis_label_text'

2024年10月24日8虾米哥

我正在尝试在 APLpy 中为颜色条编写标题,但每次我这样做时都会收到以下错误:

AttributeError:'Colorbar' object has no attribute 'set_axis_label_text' 

我使用的代码如下:

import aplpy 
import matplotlib.pyplot as plt 
fig = plt.figure() 
f1 = aplpy.FITSFigure('random.fits', figure=fig) 
f1.show_colorscale(stretch='arcsinh',cmap='Greys',interpolation="bicubic") 
f1.add_colorbar() 
f1.colorbar.set_width(0.3) 
f1.colorbar.set_axis_label_text('title') 
plt.show() 

根据阅读文档,这应该有效 http://aplpy.readthedocs.org/en/v0.9.9/quick_reference.html

请您参考如下方法:

请将 APLpy 更新到最新版本。我找遍了所有地方,但我什至没有在 0.9.6 上找到任何东西。所以可能该方法是在以后的版本中引入的。

我认为为颜色条设置标签是在 0.9.9 中引入的在 pull request #93 .