首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AttributeError: FITSFigure对象没有属性“set_tick_labels_font”

AttributeError: FITSFigure对象没有属性“set_tick_labels_font”
EN

Stack Overflow用户
提问于 2021-12-29 04:38:41
回答 1查看 153关注 0票数 0

我是编程的初学者。我试图使用APLpy和子图以及简单的代码生成两个图。

守则如下:

代码语言:javascript
复制
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’

你能帮帮我吗?

提前感谢

EN

回答 1

Stack Overflow用户

发布于 2021-12-29 05:25:04

请参考文档 for FITSFigure。发生此错误是因为hide_yaxis_labelset_tick_labels_font方法不存在于FITSFigure类中,因此不能使用它们。

将代码更改如下:

f2.set_tick_labels_fontf2.tick_labels.set_font(size = 'small')

hide_yaxis_labelsaxis_labels.hide_x()

hide_ytick_labelstick_labels.hide_x()

在代码中使用类/包之前,请阅读它的文档。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70515185

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档