I started to work with APLpy lately to slice my data cubes into 2D plots. So nice and wonderful! But - like always - I stumbled upon an issue... The argument slices the Z dimension of the cube. I also want to control where my axes X and Y begin and finish.
In the example below, I'll show how I solved this problem:
import matplotlib
matplotlib.use('Agg')
import aplpy
# to slice the data cube at Z = 47:
img = aplpy.FITSFigure('figure.fits', dimensions=[0, 1], slices=[47])
# show the image in the canvas:
img.show_grayscale()
# to get the limits of X and Y coordinates:
img._ax1.get_xlim()
# (0,100) --> APLpy will return this limits, here in pixels for instance
img._ax1.get_ylim()
# (0, 200)
# now, to set the limits of X and Y:
img._ax1.set_xlim(25, 75) # like a zoom in your plot
img.show_grayscale() # don't forget to refreshyour plot!
img._ax1.set_ylim(50, 150) # 100 to the left, 100 to the right, in pixel
img.show_grayscale()
I found that's simply like to create a subplot. That's worked for me! :)
Nenhum comentário:
Postar um comentário