def plot_time_selection(self): arms = [ (k, v.p) for k,v in self.arms.iteritems() ] sorted_arms = sorted(arms, key = lambda x: x[1]) data_sets = [] data_labels = [] for algo in self.pts.keys(): data = [] for pt in self.pts[algo]: budget = sum([len(v) for v in pt.values()]) best = self._get_best(pt) best_idx = [x[0] for x in sorted_arms].index(best) data.append((budget, best_idx)) xvals = [pt[0] for pt in data] yvals = [pt[1] for pt in data] data_sets.append((xvals, yvals)) data_labels.append(algo) make_plots.plot(data_sets, colors[:len(data_sets)], [True for x in data_sets], group_labels=data_labels, plot_xlabel = 'Budget', plot_ylabel = 'Selected Arm')
def plotLoss(train, val): plot( [[train[:, 1], train[:, 2]], [val[:, 1], val[:, 2]]], series_colors=['green', 'red'], series_labels=['Training', 'Validation'], plot_ylim=[0, 9], show_plot=False, plot_xlabel='Number of Steps', plot_ylabel='Loss', #plot_title='Loss using Inception Net', savefile='figs/{}_loss.pdf'.format(networkName))
def plotAccuracy(train, val): plot( [[train[:, 1], train[:, 2]], [val[:, 1], val[:, 2]]], series_colors=['green', 'red'], series_labels=['Training', 'Validation'], plot_ylim=[0, 0.8], show_plot=False, plot_xlabel='Number of Steps', plot_ylabel='Accuracy', #savefile_size=(2.5, 1.5), #plot_title='Accuracy using Inception Net', savefile='figs/{}_accuracy.pdf'.format(networkName))
def plot_arm_dist(self, dist): num_samples = 100000 if dist == 'uniform': pvals = numpy.random.random_sample(num_samples) elif dist == 'gauss-left': pvals = numpy.random.normal(0.3, 0.1, num_samples) elif dist == 'gauss-right': pvals = numpy.random.normal(0.7, 0.1, num_samples) edges = numpy.arange(0., 1., 0.01) vals, edges = numpy.histogram(pvals, edges, density=True) centers = [edges[i] + 0.5*(edges[i+1] - edges[i]) for i in range(len(edges)-1)] make_plots.plot([(centers, vals)], ['grey'], group_color_emphasis=[True], plot_ylim=[0, max(vals)+0.01], show_plot=True)
import scipy import numpy as np import ss_plotting.make_plots as ss import matplotlib.pyplot as plt data = np.loadtxt("./reproj_error.txt", delimiter=' ') plt.plot(data) plt.show() rows = data.shape t = range(0, rows[0]) ss.plot(series=[(t, data)], series_colors=['blue'], y_grid=True, series_labels=[''], plot_xlabel="Iterations", plot_ylabel=" Median Reprojection Error (Pixels)", savefile="./reproj_error.pdf", savefile_size=(2, 2)) #plt.yscale('log') plt.show()
import numpy as np import ss_plotting.make_plots as ss import matplotlib.pyplot as plt data = np.loadtxt("./extrinsic_errors.txt", delimiter=' ') plt.plot(data[:, 0:6] - data[:, 7:13]) plt.show() rows = data.shape # x y z x y z w x' y' z' w' x' y' z' # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 t = range(0, rows[0]) ss.plot(series=[(t, -(data[:, 0] - data[:, 7])), (t, -(data[:, 1] - data[:, 8])), (t, -(data[:, 2] - data[:, 9]))], series_colors=['red', 'green', 'blue'], series_labels=['X Error', 'Y Error', 'Z Error'], plot_xlabel="Iteration", plot_ylabel="Meters", savefile="./extrinsic_error.pdf", savefile_size=(3, 3), y_grid=True) #plt.yscale('log') plt.show() ss.plot(series=[(t, -(data[:, 3] - data[:, 10])), (t, -(data[:, 4] - data[:, 11])), (t, -(data[:, 5] - data[:, 12])), (t, -(data[:, 6] - data[:, 13]))], series_colors=['red', 'green', 'blue', 'black'], series_labels=['QX Error', 'QY Error', 'QZ Error', 'QW Error'], plot_xlabel="Iteration", plot_ylabel="Radians",
import numpy as np from ss_plotting.make_plots import plot import matplotlib.pyplot as plt data_translation = [ 0.221, 0.306, 0.323, 0.337, 0.474, 0.205, 0.388, 0.499, 0.261, 0.625, 0.393, 0.508, 0.456 ] test_translation = [ 0, 0, 0, 0, 0, 0.001, 0, 0.032, 0.024, 0.084, 0.081, 0.077, 0.075 ] x_trans = np.arange(0.65, 1.85, 0.1) series = [(x_trans, data_translation), (x_trans, test_translation)] series_labels = ['RGB', 'RGBD'] series_colors = ['red', 'blue'] ylabel = 'Error Percentage' xlabel = 'Distance (cm)' title = 'Rotation Error vs Distance with sigma = 0.5 pixels' fig, ax = plot(series, series_labels=series_labels, series_colors=series_colors, linewidth=5, plot_ylabel=ylabel, plot_xlabel=xlabel, plot_title=title, fontsize=13, legend_fontsize=13)
0.252, 0.246, 0.254, 0.282, 0.262, 0.236, 0.204, 0.27, 0.262, 0.274, 0.256, 0.26, 0.284, 0.316, 0.27, 0.266, 0.294, 0.278, 0.27, 0.278, 0.298, 0.296, 0.302, 0.324, 0.322, 0.332, 0.3, 0.34, 0.336, 0.352, 0.318, 0.348, 0.368, 0.322, 0.328, 0.312, 0.326, 0.364, 0.378, 0.346, 0.342, 0.348, 0.332, 0.34, 0.37, 0.328, 0.36, 0.344, 0.38, 0.344, 0.324, 0.37, 0.372, 0.394, 0.384, 0.38, 0.36, 0.406, 0.4, 0.406, 0.346, 0.372, 0.372, 0.402, 0.358, 0.368, 0.418, 0.4, 0.368, 0.338, 0.39, 0.396, 0.404, 0.38, 0.406, 0.406, 0.414 ] x_trans = np.arange(0.6, 1.8, 0.01) series = [(x_trans, data_translation)] series_labels = ['Simulated Data'] series_colors = ['red'] fig, ax = plot(series, series_labels=series_labels, series_colors=series_colors, linewidth=5) data_rotation = [ 0, 0, 0, 0, 0, 0, 0, 0, 0.008, 0.014, 0.046, 0.058, 0.112, 0.14, 0.182, 0.226, 0.328, 0.284, 0.276, 0.346, 0.322, 0.312, 0.36, 0.34, 0.31, 0.3, 0.298, 0.324, 0.296, 0.29, 0.274, 0.254, 0.286, 0.262, 0.254, 0.24, 0.224, 0.23, 0.208, 0.222, 0.216, 0.2, 0.182, 0.194, 0.168, 0.212, 0.178, 0.182, 0.196, 0.152, 0.174, 0.16, 0.16, 0.2, 0.168, 0.164, 0.154, 0.134, 0.156, 0.16, 0.13, 0.154, 0.134, 0.162, 0.144, 0.154, 0.114, 0.124, 0.126, 0.138, 0.144, 0.114, 0.104, 0.11, 0.098, 0.136, 0.098, 0.108, 0.096, 0.096, 0.116, 0.11, 0.12, 0.134, 0.132, 0.114, 0.126, 0.152, 0.136, 0.172 ] x_rot = np.arange(90) series2 = [(x_rot, data_rotation)] series_labels2 = ['Simulated Data']
] data_trans_05 = [ 0.0143, 0.0353, 0.0545, 0.0845, 0.1165, 0.1312, 0.1629, 0.1843, 0.216, 0.2415, 0.2641, 0.2692, 0.287, 0.3092, 0.3197, 0.3441, 0.3511, 0.3561, 0.3571, 0.3681, 0.3707, 0.3938, 0.397, 0.4062, 0.4131 ] data_trans_10 = [ 0.1432, 0.1731, 0.2059, 0.2486, 0.2687, 0.3041, 0.3129, 0.3364, 0.3514, 0.3628, 0.3662, 0.3786, 0.3956, 0.4024, 0.4087, 0.4123, 0.4254, 0.4373, 0.4313, 0.4301, 0.4423, 0.4479, 0.4496, 0.4449, 0.4646 ] x_rot = np.arange(0.65, 1.85, 0.05) series2 = [(x_rot, data_trans_02), (x_rot, data_trans_05), (x_rot, data_trans_10)] series_labels2 = ['sigma: 0.2 pixel', 'sigma: 0.5 pixel', 'sigma: 1.0 pixel'] series_colors2 = ['green', 'purple', 'orange'] ylabel = 'Error Percentage' xlabel = 'Distance (m)' title = 'Distance Error (Simulation)' fig2, ax2 = plot(series2, series_labels=series_labels2, series_colors=series_colors2, plot_ylabel=ylabel, plot_xlabel=xlabel, plot_title=title, linewidth=5, fontsize=15, legend_fontsize=15) plt.show()
import scipy import numpy as np import ss_plotting.make_plots as ss import matplotlib.pyplot as plt data = np.loadtxt("./position_error.txt", delimiter=' ') plt.plot(data) plt.show() rows = data.shape t = range(0, rows[0]) ss.plot(series=[(t, data[:, 0] - data[:, 3]), (t, data[:, 1] - data[:, 4]), (t, data[:, 2] - data[:, 5])], series_colors=['red', 'green', 'blue'], y_grid=True, series_labels=['X Error', 'Y Error', 'Z Error'], plot_xlabel="Frame", plot_ylabel="Meters", savefile="./position_error.pdf", savefile_size=(3, 3)) #plt.yscale('log') plt.show()
#!bin/python from IPython import embed import numpy import matplotlib.pyplot as plt import scipy.stats as stats import ss_plotting.make_plots as ss; data = numpy.loadtxt(open("./dot_data.txt", "rb"), delimiter=' '); theta = numpy.linspace(0, 3.14 * 2) xes = numpy.sin(theta) * 2 yes = numpy.cos(theta) * 2 ss.plot(series=[(xes, yes), (data[:, 0], data[:, 1]), (data[:, 2], data[:, 3])], series_colors=['red', 'blue', 'green'], series_labels=['Dot Perimeter', 'Touches -- Dense Tracking', 'Touches -- Open Loop'], plot_xlabel='X error (cm)', plot_ylabel="Y error (cm)", savefile="./dots.pdf", line_styles=['-', '', ''], plot_markers=['', '.', 'x'], plot_xlim=(-8, 8), plot_ylim=(-8, 8), savefile_size = (3, 3)); plt.show();
def myfunc(row): return numpy.sum(row) > 0.0001 print "Loading..." data = numpy.loadtxt('./offsets.txt', delimiter=' ') #data = data[numpy.array([myfunc(row) for row in data])] m = numpy.max(numpy.abs(data)) t = xrange(1, 200) ss.plot(series=[(t, data[1:200, 1]), (t, data[1:200, 2])], series_colors=['blue', 'red'], y_grid=True, series_labels=['$q_2$', '$q_3$'], plot_xlabel="Frame", plot_ylabel="Offset (rad)", savefile="./kinematic_redundancy.pdf", savefile_size=(4, 3)) plt.plot(t, data[1:200, 1], '-') plt.plot(t, data[1:200, 2], '-') plt.show() f, axarr = plt.subplots(3, 2, sharex=True) for i in xrange(0, 6): ax = axarr[i / 2, i % 2] ax.plot(data[:, i], '.', color=(0.6, 0.0, 0.0)) ax.plot(data[:, i + 6], '.', color=(0.6, 0.6, 0.6)) #ax.plot(smooth(data[:, i], 9), '-', color=(0, 0, 0));
import numpy as np; import ss_plotting.make_plots as ss; import matplotlib.pyplot as plt; import os datas = dict(); ts = []; errs = []; for dirname, dirnames, filenames in os.walk('.'): dirnames = sorted(dirnames) # print path to all subdirectories first. for subdirname in dirnames: print subdirname datas[subdirname] = np.loadtxt(os.path.join(dirname, subdirname) + "/extrinsic_error.txt") ts.append(float(subdirname)) errs.append(50 * np.sqrt(np.dot(np.transpose(datas[subdirname][7:10]), datas[subdirname][7:10]))); # print path to all filenames. #for filename in filenames: # print(os.path.join(dirname, filename)) ss.plot(series=[(ts, errs)], series_colors=['blue'], series_labels=[''], plot_xlabel="Camera field of view (degrees)", plot_ylabel="Final Extrinsic Error (cm)", savefile="./extrinsic_fov.pdf", savefile_size=(3, 3), y_grid=True, line_styles=[''], plot_markers=['.']); ##print errs ##plt.plot(ts, errs, 'x') ##plt.show();
group_color_emphasis = [True], group_labels = None, plot_ylabel = 'Counts', plot_xlabel = 'Success Probability', bin_labels = bin_edges + 0.5*bin_size, savefile = savefile, savefile_size = (.5*4.75, .5*.5*4.75)) # Add expected value data all_data.append((xvals, expected_vals)) all_labels.append('Expected - %s' % arm_dist) all_colors.append(colors[aidx]) # all_color_emphasis.append(False) all_color_emphasis.append(True) # Add actual value data # all_data.append((xvals, actual_vals)) # all_labels.append('Actual - %s' % arm_dist) # all_colors.append(colors[aidx]) # all_color_emphasis.append(True) savefile = 'comparison.png' if args.save_plots else None make_plots.plot(all_data, all_colors, group_color_emphasis = all_color_emphasis, group_labels = all_labels, plot_xlabel = 'Num selected arms', plot_ylabel = 'Success probability', fontsize=8, legend_fontsize=8, savefile = savefile, savefile_size = (.5*4.75, 1.5*.5*4.75))