[英]AttributeError: 'FITSFigure' object has no attribute 'set_tick_labels_font'
I am beginner in programing and trying to produce two plots using aplpy and subplot and simple code.我是编程的初学者,并尝试使用 aplpy 和 subplot 以及简单的代码生成两个图。 The code is as following:
代码如下:
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()
It gives me error: AttributeError: 'FITSFigure' object has no attribute 'set_tick_labels_font'它给了我错误: AttributeError: 'FITSFigure' object has no attribute 'set_tick_labels_font'
Could you please help me.请你帮助我好吗。
Thanks in advance提前致谢
Refer the docs for FITSFigure.请参阅 FITSFigure 的文档。 The error occurs because
hide_yaxis_label
and set_tick_labels_font
methods dont exist in FITSFigure class so you cannot use them.发生该错误是因为
hide_yaxis_label
class 中不存在 hide_yaxis_label 和set_tick_labels_font
方法,因此您无法使用它们。
Change the code as follows:更改代码如下:
f2.set_tick_labels_font
to f2.tick_labels.set_font(size = 'small')
f2.set_tick_labels_font
到f2.tick_labels.set_font(size = 'small')
hide_yaxis_labels
to axis_labels.hide_x()
hide_yaxis_labels
到axis_labels.hide_x()
hide_ytick_labels
to tick_labels.hide_x()
hide_ytick_labels
到tick_labels.hide_x()
Please read the documents for class/package before using it in your code.在您的代码中使用它之前,请阅读类/包的文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.