pyplot 放大

问题描述 投票:0回答:2

我正在尝试从灵活图像传输系统(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'] # Let's 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]
开始的区域?

python matplotlib zooming
2个回答
55
投票

根据您的限制使用

plt.axis()
功能。

plt.axis([x_min, x_max, y_min, y_max])

其中

x_min
x_max
y_min
y_max
是两个轴的坐标限制。


25
投票

这个问题与你如何操作

pyfits
无关,而只是添加

的问题
plt.xlim(1.3, 4.0)

之前的代码

plt.show()

© www.soinside.com 2019 - 2024. All rights reserved.