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