How can I duplicate this simple matlab plot functionality with mathplotlib?

matlab, python

Solution

import matplotlib.pyplot as plt
import numpy as np

arr=np.genfromtxt('foo.csv',delimiter=',')
plt.plot(arr[:,0],arr[:,1],'b-')
plt.show()

on this data (foo.csv):

1,2
2,4
3,9

produces

When you setup the matplotlibrc, one of the key parameters you need to set is the `backend`. Which backend you choose depends on your OS and installation. For any typical OS there should be a backend that allows you to pan and zoom the plot interactively. (`GtkAgg` works on Ubuntu). The buttons highlighted in red allow you to pan and zoom, respectively.

Problem

Here is a simple matlab script to read a csv file, and generate a plot (with which I can zoom in with the mouse as I desire). I would like to see an example of how this is done in python and mathplotlib. ``` data = csvread('foo.csv'); % read csv data into vector 'data' figure; % create figure plot (data, 'b'); % plot the data in blue ``` In general, the examples in mathplotlib tutorials I've seen will create a static graph, but it's not interactively "zoomable". Would any python expert care to share an equivalent? Thanks

Original source