annotate trunk/experiments/scripts/cnbh-syllables/results_plotting/spider_plot.py @ 381:e6f006238034

- Python results plotting (finally). - Proper results reporting script. - Test on ALL talkers. The results script then generates a summary based on all the various subsets. - Fixed chown users (hopefully sudos to be deleted entirely soon) - More...
author tomwalters
date Mon, 13 Sep 2010 18:34:23 +0000
parents
children 068e33a65f8d
rev   line source
tomwalters@381 1 #!/usr/bin/env python
tomwalters@381 2 """
tomwalters@381 3 spider_plot.py
tomwalters@381 4
tomwalters@381 5 Created by Thomas Walters on 2010-09-12.
tomwalters@381 6 Copyright 2010 Google. All rights reserved.
tomwalters@381 7 """
tomwalters@381 8
tomwalters@381 9 import numpy as np
tomwalters@381 10 import pylab as p
tomwalters@381 11 import mpl_toolkits.mplot3d.axes3d as p3
tomwalters@381 12 import matplotlib as mpl
tomwalters@381 13 from matplotlib import cm
tomwalters@381 14 import matplotlib.ticker as ticker
tomwalters@381 15
tomwalters@381 16 total_value_count=185
tomwalters@381 17
tomwalters@381 18 central_vtl=15
tomwalters@381 19 central_vtl_scaling=112.32
tomwalters@381 20
tomwalters@381 21 # Read in a file with lines in the form
tomwalters@381 22 # Pitch Scale Percentage
tomwalters@381 23 xs=[]
tomwalters@381 24 ys=[]
tomwalters@381 25 zs=[]
tomwalters@381 26 f = open('plottable_results.txt', 'r')
tomwalters@381 27 for line in f:
tomwalters@381 28 if line[0] != "#":
tomwalters@381 29 values = line.strip().split(' ')
tomwalters@381 30 xs.append(central_vtl*central_vtl_scaling/float(values[1]))
tomwalters@381 31 ys.append(float(values[0]))
tomwalters@381 32 zs.append(float(values[2]))
tomwalters@381 33
tomwalters@381 34
tomwalters@381 35 # Define a tiny sphere, centered on the origin, which
tomwalters@381 36 # we'll shift to the desired position.
tomwalters@381 37 u=np.r_[0:2*np.pi:50j]
tomwalters@381 38 v=np.r_[0:np.pi:50j]
tomwalters@381 39 sx=0.01*np.outer(np.cos(u),np.sin(v))
tomwalters@381 40 sy=0.01*np.outer(np.sin(u),np.sin(v))
tomwalters@381 41 sz=2.5*np.outer(np.ones(np.size(u)),np.cos(v))
tomwalters@381 42
tomwalters@381 43 fig=p.figure()
tomwalters@381 44 ax = p3.Axes3D(fig, azim=-80, elev=60)
tomwalters@381 45
tomwalters@381 46 colormap = cm.get_cmap('jet', 100)
tomwalters@381 47
tomwalters@381 48 # Note: here I fake out the lack of proper logarihmic scales on 3D axes in
tomwalters@381 49 # matplotlib by just plotting log values on a linear scale and renaming
tomwalters@381 50 # the labels.
tomwalters@381 51 # (This doesn't work: ax.w_yaxis.set_scale('log') ax.w_xaxis.set_scale('log'))
tomwalters@381 52
tomwalters@381 53 # Plot the values seven at a time as dark lines.
tomwalters@381 54 # These are the individual spokes of the spoke pattern.
tomwalters@381 55 n=7
tomwalters@381 56 for i in xrange(0,8):
tomwalters@381 57 ax.plot(np.log(xs[i*n:(i+1)*n]), np.log(ys[i*n:(i+1)*n]), zs[i*n:(i+1)*n], color=[0,0,0])
tomwalters@381 58
tomwalters@381 59 for x,y,z in zip(xs,ys,zs):
tomwalters@381 60 ax.plot(np.log([x, x]), np.log([y, y]), [z, 0], color=[0.8,0.8,0.8])
tomwalters@381 61 ax.plot_surface(sx+np.log(x),sy+np.log(y),sz+z, color=colormap(int(z)), linewidth=0)
tomwalters@381 62
tomwalters@381 63 ax.set_ylabel('GPR/Hz')
tomwalters@381 64 ax.set_xlabel('VTL/cm')
tomwalters@381 65 ax.set_zlabel('Percent correct')
tomwalters@381 66 ax.set_ylim3d(np.log([131,225]))
tomwalters@381 67 ax.set_xlim3d(np.log([9.9, 22.1]))
tomwalters@381 68 ax.set_zlim3d([-1, 101])
tomwalters@381 69 ax.w_zaxis.set_major_locator(ticker.FixedLocator([0, 20, 40, 60, 80, 100]))
tomwalters@381 70
tomwalters@381 71 ax.w_xaxis.set_major_locator(ticker.FixedLocator(np.log([10,15,22])))
tomwalters@381 72 ax.w_xaxis.set_ticklabels(['10', '15', '22'])
tomwalters@381 73 ax.w_yaxis.set_major_locator(ticker.FixedLocator(np.log([132, 172, 224])))
tomwalters@381 74 ax.w_yaxis.set_ticklabels(['132', '172', '224'])
tomwalters@381 75
tomwalters@381 76 #for a in ax.w_xaxis.get_ticklines()+ax.w_xaxis.get_ticklabels():
tomwalters@381 77 # a.set_visible(False)
tomwalters@381 78
tomwalters@381 79 #for a in ax.w_yaxis.get_ticklines()+ax.w_yaxis.get_ticklabels():
tomwalters@381 80 # a.set_visible(False)
tomwalters@381 81
tomwalters@381 82
tomwalters@381 83 #p.show()
tomwalters@381 84 p.savefig('results.png')
tomwalters@381 85