def style_1d_sensel_func(pylab, n, y_max, extra_vspace=1.1): """ Decorates approapriateyle """ y_axis_set(pylab, -y_max * extra_vspace, y_max * extra_vspace) x_axis_set(pylab, -1, n) turn_off_bottom_and_top(pylab) turn_off_right(pylab) set_left_spines_outward(pylab, offset=10) set_thick_ticks(pylab, markersize=3, markeredgewidth=1) pylab.plot([0, n - 1], [0, 0], "--", color=[0.7, 0.7, 0.7])
def display_1d_tensor(pub, name, value): with pub.plot(name) as pylab: for k in range(value.shape[0]): x = value[k, ...].squeeze() assert x.ndim == 1 pylab.plot(x, label="%s%s" % (name, k)) x_axis_set(pylab, -1, x.size) turn_off_bottom_and_top(pylab) y_axis_balanced(pylab, show0=True) pylab.legend()
def publish(self, pub): if not self.once: pub.text('info', 'never called yet') return N = self.last_y.size with pub.plot('last_w') as pylab: pylab.plot(self.last_w, 's') x_axis_set(pylab, -1, N) y_axis_set(pylab, -0.1, 1.1) turn_off_bottom_and_top(pylab) gy0 = self.last_gy[0, :] def plot_good_bad(pylab, x, valid): invalid = np.logical_not(valid) pylab.plot(np.nonzero(valid)[0], x[valid], 'ks') pylab.plot(np.nonzero(invalid)[0], x[invalid], 'rs') with pub.plot('last_y') as pylab: plot_good_bad(pylab, self.last_y, self.last_y_valid) y_axis_set(pylab, -0.1, +1.1) x_axis_set(pylab, -1, N) turn_off_bottom_and_top(pylab) with pub.plot('last_y_dot') as pylab: pylab.plot(self.last_y_dot) plot_good_bad(pylab, self.last_y_dot, self.last_y_dot_valid) upper = np.ones(N) * self.max_y_dot lower = -upper pylab.plot(upper, 'r--') pylab.plot(lower, 'r--') x_axis_set(pylab, -1, N) y_axis_balanced(pylab) turn_off_bottom_and_top(pylab) with pub.plot('last_gy') as pylab: plot_good_bad(pylab, gy0, self.last_gy_valid) upper = np.ones(N) * self.max_gy lower = -upper pylab.plot(upper, 'r--') pylab.plot(lower, 'r--') x_axis_set(pylab, -1, N) y_axis_balanced(pylab) turn_off_bottom_and_top(pylab) self.w_stats.publish(pub.section('w_stats'))
def display_1d_field(pub, name, value): with pub.plot(name) as pylab: pylab.plot(value) x_axis_set(pylab, -1, value.size) turn_off_bottom_and_top(pylab)