Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyplot zooming in

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) 

How could I only plot the region from [1.3 to 4] in the x-axis?

like image 667
Dax Feliz Avatar asked Jul 09 '12 18:07

Dax Feliz


People also ask

How do you zoom in in Pyplot?

If you press 'x' or 'y' while panning the motion will be constrained to the x or y axis, respectively. Press the right mouse button to zoom, dragging it to a new position. The x axis will be zoomed in proportionate to the rightward movement and zoomed out proportionate to the leftward movement.

What is Pyplot CLF ()?

The clf() function in pyplot module of matplotlib library is used to clear the current figure.


1 Answers

Use the plt.axis() function with your limits.

plt.axis([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.

like image 64
MaxPowers Avatar answered Sep 21 '22 01:09

MaxPowers