Good afternoon, I am using the following to code to plot the output from an optical encoder:
import numpy as np from numpy import ma, logical_or import pylab from pylab import * import matplotlib.pyplot as plt from matplotlib.ticker import AutoMinorLocator import sys # Defining x and y minorlocator xminorLocator=AutoMinorLocator() yminorLocator=AutoMinorLocator() # Load data from .txt file data = np.loadtxt('2014_12_04-16_30_03.txt',skiprows = 0 ,usecols = (0,1)) print "\n Chopper Test for X-SPEC Prototype" print "\n Time (sec) Pos (deg)" print data # Place column data in array to be plotted time = np.array(data[:,0]) print "Time (sec):" #print time pos = np.array(data[:,1]) print "Position (deg):" print pos # Setting minor ticks ax = plt.subplot(111) ax.xaxis.set_minor_locator(xminorLocator) ax.yaxis.set_minor_locator(yminorLocator) #Plotting commands. subplot(2,1,1) plot(time, pos, 'ro') title('Encoder Output') ylabel('Pos (deg)') subplot(2,1,2) plot(t_small, pos, 'ro') xlabel('Time (sec)') ylabel('Pos (deg)') show() The desired result is a square wave, but this is not readily available from the plot (see attached). For the subplot(2,1,2) I would like to plot the output over a 5 second interval so that the behaviour becomes more evident. Can someone please advise me as to the easiest way isolate the first 5 seconds of data? Thank you.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor