我试图从FITS文件中绘制一些数据,我想知道是否有人知道如何关注绘图轴的某些区域?以下是一些示例代码:
import pyfits
from matplotlib import pyplot as plt
from matplotlib import pylab
from pylab import *
#Assuming I have my data in the current directory
a = pyfits.getdata('fits1.fits')
x = a['data1'] # Lets assume data1 is the column: [0, 1, 1.3, 1.5, 2, 4, 8]
y = a['data2'] # And data2 is the column: [0, 0.5, 1, 1.5, 2, 2.5, 3]
plt.plot(x,y)
我怎样才能在x轴上绘制[1.3 to 4]
的区域?
答案 0 :(得分:12)
使用plt.axis()
功能和限制。
plt.axis([xmin,xmax,ymin,ymax])
其中x(y)min/max
是两个轴的坐标限制。
答案 1 :(得分:9)
此问题与您操纵pyfits
的方式无关,只是添加
plt.xlim(1.3, 4.0)
到plt.show()