[Tutor] Plotting subsets of data

Danny Yoo dyoo at hashcollision.org
Mon Dec 8 20:49:16 CET 2014


On Mon, Dec 8, 2014 at 7:48 AM, Colin Ross <colin.ross.dal at gmail.com> wrote:
> Good afternoon,
>
> I am using the following to code to plot the output from an optical encoder:

Hi Colin,

Matplotlib is a third-party library, so you may also consider asking
the matplotlib folks.

>From a brief look at:

    http://matplotlib.org/1.4.2/users/pyplot_tutorial.html#working-with-multiple-figures-and-axes

it appears that you can override the default axis, and specify xmin,
ymin, xmax, and ymax values.

    http://matplotlib.org/1.4.2/api/pyplot_api.html#matplotlib.pyplot.axis

For your particular case, you may want to just limit your x axis, in
which case xlim() might be appropriate.

    http://matplotlib.org/1.4.2/api/pyplot_api.html#matplotlib.pyplot.xlim


If all else fails, just filter your data before submitting it to the
grapher.  The program loads data here, using loadtxt
(http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html):

    data = np.loadtxt('2014_12_04-16_30_03.txt',skiprows = 0 ,usecols = (0,1))

and it's just a numpy array: you can manipulate numpy arrays.   See:

    http://stackoverflow.com/questions/26154711/filter-rows-of-a-numpy-array

as an example of an approach.


More information about the Tutor mailing list