annotate experiments/scripts/cnbh-syllables/results_plotting/spider_plot.py @ 100:ae195c41c7bd

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