我想從FITS文件中繪製一些數據,我想知道是否有人知道如何專注於繪圖軸的某些區域?下面是一些示例代碼:pyplot放大
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)
我怎麼可能只標繪出由[1.3 to 4]
該區域在x軸?
謝謝!這看起來非常有用。 – 2012-07-09 19:29:53
@ nye17使用'xlim' /'ylim'或'axis'並不重要,因爲'axis'調用'xlim' /'ylim'來執行操作。在[源代碼](https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes.py)中訪問'axis'的定義。 'axis'只是更方便一點,因爲你可以用一個命令操縱所有四個限制。 – MaxPowers 2012-07-10 14:31:48
@MaxPowers你是對的,我不知何故將它誤認爲'add_axis',我的壞! – nye17 2012-07-10 18:03:20