我是编程的初学者。我试图使用APLpy和子图以及简单的代码生成两个图。
守则如下:
import matplotlib
matplotlib.use('Agg')
import aplpy
import matplotlib.pyplot as mpl
fig = mpl.figure(figsize=(15, 7))
f1 = aplpy.FITSFigure('snr.5500-drop.fits', figure=fig, subplot=[0.1,0.1,0.35,0.8])
f1.set_tick_labels_font(size='x-small')
f1.set_axis_labels_font(size='small')
f1.show_grayscale()
f2 = aplpy.FITSFigure('snr.2100-drop.fits', figure=fig, subplot=[0.5,0.1,0.35,0.8])
f2.set_tick_labels_font(size='x-small')
f2.set_axis_labels_font(size='small')
f2.show_grayscale()
f2.hide_yaxis_label()
f2.hide_ytick_labels()
fig.canvas.draw()它给了我错误: AttributeError:'FITSFigure‘对象没有属性'set_tick_labels_font’
你能帮帮我吗?
提前感谢
发布于 2021-12-29 05:25:04
请参考文档 for FITSFigure。发生此错误是因为hide_yaxis_label和set_tick_labels_font方法不存在于FITSFigure类中,因此不能使用它们。
将代码更改如下:
f2.set_tick_labels_font到f2.tick_labels.set_font(size = 'small')
hide_yaxis_labels到axis_labels.hide_x()
hide_ytick_labels到tick_labels.hide_x()
在代码中使用类/包之前,请阅读它的文档。
https://stackoverflow.com/questions/70515185
复制相似问题