#!/usr/bin/env python from matplotlib import matlab data = ((3, 1000), (10, 3), (100, 30), (500, 800), (50, 1)) matlab.xlabel("FOO") matlab.ylabel("FOO") matlab.title("Testing") matlab.gca().set_yscale('log') dim = len(data[0]) w = 0.75 dimw = w / dim x = matlab.arange(len(data)) for i in range(len(data[0])): y = [d[i] for d in data] b = matlab.bar(x + i * dimw, y, dimw, bottom=0.001) matlab.gca().set_xticks(x + w / 2) matlab.gca().set_ylim((0.001, 1000)) matlab.show()
from psychopy import calib import matplotlib.matlab as mat myMonitor = calib.Monitor('iiyama514') #run a calibration series lumsPRE = calib.getLumSeriesPR650(1,8) gamCalc = calib.GammaCalculator(lums=lumsPRE) print "monitor gamma=%.2f" %(gamCalc.gammaVal) myMonitor['gamma'] = gamCalc.gammaVal myMonitor.save() #set the gamma value and test again lumsPOST = calib.getLumSeriesPR650(1,8,myMonitor['gamma']) mat.plot(calib.DACrange(len(lumsPRE)),lumsPRE,'bo-') mat.plot(calib.DACrange(len(lumsPOST)),lumsPOST,'ro-') mat.ylabel('cd/m^2') mat.show()
"""Load Nicolet BMSI data.""" if tmin < 0: tmin = 0 fh = file(filename, 'rb') indmin = Fs * tmin numsamples = os.path.getsize(filename) / (channels * 2) indmax = min(numsamples, Fs * tmax) byte0 = int(indmin * channels * 2) numbytes = int((indmax - indmin) * channels * 2) fh.seek(byte0) data = fromstring(fh.read(numbytes), Int16).astype(Float) data.shape = -1, channels t = (1 / Fs) * arange(indmin, indmax) return t, data t, data = read_nicolet(0, 10) x = data[:, 5] Pxx, freqs, t = specgram(x, NFFT=512, Fs=Fs, noverlap=412) T, F = meshgrid(t, freqs) pcolor(T, F, 10 * log10(Pxx), shading='flat') set(gca(), 'ylim', [0, 100]) #print Pxx.shape, freqs.shape, t.shape show()
from matplotlib.matlab import figure, close, axes, subplot, show from matplotlib.numerix import arange, sin, pi t = arange(0.0, 1.0, 0.01) fig = figure(1) ax1 = fig.add_subplot(211) ax1.plot(t, sin(2*pi*t)) ax1.grid(True) ax1.set_ylim( (-2,2) ) ax1.set_ylabel('1 Hz') ax1.set_title('A sine wave or two') for label in ax1.get_xticklabels(): label.set_color('r') ax2 = fig.add_subplot(212) ax2.plot(t, sin(2*2*pi*t)) ax2.grid(True) ax2.set_ylim( (-2,2) ) l = ax2.set_xlabel('Hi mom') l.set_color('g') l.set_fontsize('large') show()
#!/usr/bin/env python from matplotlib import matlab data = ((3,1000), (10,3), (100,30), (500, 800), (50,1)) matlab.xlabel("FOO") matlab.ylabel("FOO") matlab.title("Testing") matlab.gca().set_yscale('log') dim = len(data[0]) w = 0.75 dimw = w / dim x = matlab.arange(len(data)) for i in range(len(data[0])) : y = [d[i] for d in data] b = matlab.bar(x + i * dimw, y, dimw, bottom=0.001) matlab.gca().set_xticks(x + w / 2) matlab.gca().set_ylim( (0.001,1000)) matlab.show()
def show(): if os.name == 'nt' or os.name == 'dos' or os.name == 'ce': pylab.draw() else: pylab.show()
ax.append(MM.axes([.55, .05, .40, .40])) # lower right ax.append(MM.axes([.55, .55, .40, .40])) # upper right for i in range(4): ax[i].plot(x, [t_lst[k][i] for k in K], color=darkblue, linewidth=3) ax[i].plot(x, [t_ref[k][i] for k in K], color=lightblue, linewidth=3) ax[i].set_xticks([]) ax[i].set_title('Limited memory p = %-d' % plist[i], fontsize='small') ax[i].legend(['Python', 'Fortran'], 'upper left') for i in [2, 3]: ax[i].set_ylabel('Time (s)', fontsize='small') MM.show() # For the number of iterations, use first value of p as reference x = range(len(i_lst.keys())) ax = MM.subplot(111) lgnd = [] for i in range(len(plist)): lgnd.append('p = %-d' % plist[i]) ax.plot(x, [(1.0 * i_lst[k][0]) / i_lst[k][0] for k in K], 'k-') ax.plot(x, [(1.0 * i_lst[k][1]) / i_lst[k][0] for k in K], 'k:') ax.plot(x, [(1.0 * i_lst[k][2]) / i_lst[k][0] for k in K], 'k-.') ax.plot(x, [(1.0 * i_lst[k][3]) / i_lst[k][0] for k in K], 'k--') ax.legend(lgnd, 'upper right') ax.set_title('Number of iterations(p)/Number of iterations(0)') ax.set_xticklabels(K, rotation=45,
steelblue = '#5d82ef' x = range(len(t_lst.keys())) ax = [] ax.append(MM.axes([ .05, .05, .40, .40 ])) # lower left ax.append(MM.axes([ .05, .55, .40, .40 ])) # upper left ax.append(MM.axes([ .55, .05, .40, .40 ])) # lower right ax.append(MM.axes([ .55, .55, .40, .40 ])) # upper right for i in range(4): ax[i].plot(x, [ t_lst[k][i] for k in K ], color=darkblue, linewidth=3) ax[i].plot(x, [ t_ref[k][i] for k in K ], color=lightblue, linewidth=3) ax[i].set_xticks([]) ax[i].set_title('Limited memory p = %-d' % plist[i], fontsize='small') ax[i].legend(['Python', 'Fortran'], 'upper left') for i in [2,3]: ax[i].set_ylabel('Time (s)', fontsize='small') MM.show() # For the number of iterations, use first value of p as reference x = range(len(i_lst.keys())) ax = MM.subplot(111) lgnd = [] for i in range(len(plist)): lgnd.append('p = %-d' % plist[i]) ax.plot(x, [ (1.0*i_lst[k][0])/i_lst[k][0] for k in K ], 'k-') ax.plot(x, [ (1.0*i_lst[k][1])/i_lst[k][0] for k in K ], 'k:') ax.plot(x, [ (1.0*i_lst[k][2])/i_lst[k][0] for k in K ], 'k-.') ax.plot(x, [ (1.0*i_lst[k][3])/i_lst[k][0] for k in K ], 'k--') ax.legend(lgnd, 'upper right') ax.set_title('Number of iterations(p)/Number of iterations(0)') ax.set_xticklabels(K, rotation = 45, horizontalalignment = 'right', fontsize='small') MM.show()
from psychopy import calib import matplotlib.matlab as mat myMonitor = calib.Monitor('iiyama514') #run a calibration series lumsPRE = calib.getLumSeriesPR650(1, 8) gamCalc = calib.GammaCalculator(lums=lumsPRE) print "monitor gamma=%.2f" % (gamCalc.gammaVal) myMonitor['gamma'] = gamCalc.gammaVal myMonitor.save() #set the gamma value and test again lumsPOST = calib.getLumSeriesPR650(1, 8, myMonitor['gamma']) mat.plot(calib.DACrange(len(lumsPRE)), lumsPRE, 'bo-') mat.plot(calib.DACrange(len(lumsPOST)), lumsPOST, 'ro-') mat.ylabel('cd/m^2') mat.show()