是否有任何方法可以使多幅起伏的图形动态地共享轴,以便当一个被移动或缩放时,它会移动和缩放其他的?
我可以使用matplotlib pyplot的imshow和子图例程来实现这种影响,但是使用这些限制我的绘图的其他一些重要方面,而aplpy提供了我的图像所需的所有工具。
我试过使用matplotlib命令和一个函数来根据单击位置重新记录所有图像,但我只能放大或缩小,两者都不能放大,而且我还不能单击和拖动。
我的绘图代码的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发布于 2017-03-10 13:29:15
看来aplpy的绘图功能完全基于matplotlib。因此,任何可以用aplpy完成的绘图格式都可以用matplotlib来完成。
但是,如果您仍然想坚持创建情节,仍然应该有一个解决方案,不需要复杂的事件侦听器。
不幸的是,与绘制其他库的功能不同,aplpy似乎只接受作为参数的数字,而不是作为轴。
尽管如此,即使在斧头被创建之后,也应该有可能将其连接起来:
axes = fig.get_axes()
axes[0].get_shared_x_axes().join(axes[0], axes[1])
axes[0].get_shared_y_axes().join(axes[0], axes[1])
axes[0].autoscale() # <-- needed if no axes limits are explicitely set.https://stackoverflow.com/questions/42718823
复制相似问题