pyplot 放大 [英] pyplot zooming in
本文介绍了pyplot 放大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从FITS文件中绘制一些数据,我想知道是否有人知道如何专注于绘制轴的某些区域?下面是一些示例代码:
I am trying to plot some data from FITS files and I wanted to know if anyone knows how to focus on certain regions of a plot's axis? Here is some example code:
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到4]
的区域?
How could I only plot the region from [1.3 to 4]
in the x-axis?
推荐答案
在限制范围内使用 plt.axis()
函数.
Use the plt.axis()
function with your limits.
plt.axis([x_min, x_max, y_min, y_max])
其中 x_min
, x_max
, y_min
和 y_max
是两个轴的坐标限制.
where x_min
, x_max
, y_min
, and y_max
are the coordinate limits for both axes.
这篇关于pyplot 放大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文