小编Ale*_*ard的帖子

Aplpy多图动态轴共享

有什么方法可以使多图aplpy图动态共享轴,以便在移动或缩放一个轴时移动另一个轴并对其进行缩放?

我可以使用matplotlib pyplot的imshow和subplot例程来实现效果,但是使用这些限制了我绘图的其他一些重要方面,而aplpy提供了我的图像所需的所有工具。

我尝试使用matplotlib cid命令和一个功能来根据单击位置更新所有图像,但是我只能放大或缩小,不能同时放大和缩小,而且我还不能单击和拖动。

我的绘图代码的MWE如下:

from astropy.io import fits
import matplotlib.pyplot as plt
import aplpy

root = '/my/data/directory/'
data = '3d_image.fits'

hdu = fits.open(root + data)[0]
hdr = hdu.header

fits1 = fits.PrimaryHDU(data = hdu.data[4,:,:], header = hdr)
fits2 = fits.PrimaryHDU(data = hdu.data[6,:,:], header = hdr)

fig = plt.figure(figsize=(15, 15))

f1 = aplpy.FITSFigure(fits1, figure=fig, subplot=[0.1,0.1,0.8,0.35])
f1.show_colorscale(cmap = 'coolwarm', vmin = 8., vmax = 10.5)

f2 = aplpy.FITSFigure(fits2, figure=fig, subplot=[0.1,0.5,0.8,0.35])
f2.show_colorscale(cmap = 'coolwarm', vmin = 1.2, vmax = 1.6)

fig.show
Run Code Online (Sandbox Code Playgroud)

python interactive axes matplotlib aplpy

4
推荐指数
1
解决办法
1142
查看次数

标签 统计

aplpy ×1

axes ×1

interactive ×1

matplotlib ×1

python ×1