简体   繁体   English

AttributeError: 'FITSFigure' object 没有属性 'set_tick_labels_font'

[英]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_fontf2.tick_labels.set_font(size = 'small')

hide_yaxis_labels to axis_labels.hide_x() hide_yaxis_labelsaxis_labels.hide_x()

hide_ytick_labels to tick_labels.hide_x() hide_ytick_labelstick_labels.hide_x()

Please read the documents for class/package before using it in your code.在您的代码中使用它之前,请阅读类/包的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 APLpy属性错误:“模块”对象没有属性“ FITSfigure” - APLpy attribute error : 'module' object has no attribute 'FITSfigure' AttributeError:“ ...”对象没有属性“ *** _ set” - AttributeError: '…' object has no attribute '***_set' AttributeError: '...' object 没有属性 '_set' - AttributeError: '…' object has no attribute '_set' AttributeError:“函数”对象没有属性“ labels_” - AttributeError: 'function' object has no attribute 'labels_' Python:AttributeError:'str'对象没有属性'font' - Python: AttributeError: 'str' object has no attribute 'font' AttributeError: '***' 对象没有属性 '***_set' - AttributeError: '***' object has no attribute '***_set' Holoviews:AttributeError:'图像'对象没有属性'设置' - Holoviews: AttributeError: 'Image' object has no attribute 'set' AttributeError: 'str' 对象没有带有 StringVar 的属性 'set' - AttributeError: 'str' object has no attribute 'set' with a StringVar Tkinter-AttributeError:“ str”对象没有属性“ set” - Tkinter - AttributeError: 'str' object has no attribute 'set' AttributeError:'set'对象没有属性'items' - AttributeError: 'set' object has no attribute 'items'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM