def test_plot_limits(): fig1, ax1 = plot_limits(fig, ax) nt.ok_(ax1.get_xlim() == xlim) nt.ok_(ax1.get_ylim() == ylim) fig1, ax1 = plot_limits(fig, ax, xlim=(0, 100), ylim=(-100, 0)) nt.ok_(ax1.get_xlim() == (0, 100)) nt.ok_(ax1.get_ylim() == (-100, 0)) fig2, ax2 = plot_limits(fig0, ax0) nt.ok_(np.allclose(ax2.get_zlim(), zlim0)) fig2, ax2 = plot_limits(fig0, ax0, zlim=(0, 100)) nt.ok_(np.allclose(ax2.get_zlim(), (0, 100)))
def test_plot_limits(): fig1, ax1 = plot_limits(fig, ax) nt.ok_(ax1.get_xlim() == xlim) nt.ok_(ax1.get_ylim() == ylim) fig1, ax1 = plot_limits(fig, ax, xlim=(0,100), ylim=(-100,0)) nt.ok_(ax1.get_xlim() == (0,100)) nt.ok_(ax1.get_ylim() == (-100,0)) fig2, ax2 = plot_limits(fig0, ax0) nt.ok_(np.allclose(ax2.get_zlim(), zlim0)) fig2, ax2 = plot_limits(fig0, ax0, zlim=(0,100)) nt.ok_(np.allclose(ax2.get_zlim(), (0,100)))
def main(data_dir, mtype_file): # pylint: disable=too-many-locals '''Run the stuff''' # data structure to store results stuff = load_neurite_features(data_dir) sim_params = json.load(open(mtype_file)) # load histograms, distribution parameter sets and figures into arrays. # To plot figures, do # plots[i].fig.show() # To modify an axis, do # plots[i].ax.something() _plots = [] for feat, d in stuff.items(): for typ, data in d.items(): dist = sim_params['components'][typ].get(feat, None) print('Type = %s, Feature = %s, Distribution = %s' % (typ, feat, dist)) # if no data available, skip this feature if not data: print("No data found for feature %s (%s)" % (feat, typ)) continue # print 'DATA', data num_bins = 100 limits = calc_limits(data, dist) bin_edges = np.linspace(limits[0], limits[1], num_bins + 1) histo = np.histogram(data, bin_edges, normed=True) print('PLOT LIMITS:', limits) # print 'DATA:', data # print 'BIN HEIGHT', histo[0] plot = Plot(*view_utils.get_figure(new_fig=True, subplot=111)) view_utils.plot_limits(plot.fig, plot.ax, xlim=limits, no_ylim=True) plot.ax.bar(histo[1][:-1], histo[0], width=bin_widths(histo[1])) dp, bc = dist_points(histo[1], dist) # print 'BIN CENTERS:', bc, len(bc) if dp is not None: # print 'DIST POINTS:', dp, len(dp) plot.ax.plot(bc, dp, 'r*') plot.ax.set_title('%s (%s)' % (feat, typ)) _plots.append(plot) return _plots
def main(data_dir, mtype_file): # pylint: disable=too-many-locals """Run the stuff""" # data structure to store results stuff = load_neurite_features(data_dir) sim_params = json.load(open(mtype_file)) # load histograms, distribution parameter sets and figures into arrays. # To plot figures, do # plots[i].fig.show() # To modify an axis, do # plots[i].ax.something() _plots = [] for feat, d in stuff.items(): for typ, data in d.items(): dist = sim_params["components"][typ].get(feat, None) print("Type = %s, Feature = %s, Distribution = %s" % (typ, feat, dist)) # if no data available, skip this feature if not data: print("No data found for feature %s (%s)" % (feat, typ)) continue # print 'DATA', data num_bins = 100 limits = calc_limits(data, dist) bin_edges = np.linspace(limits[0], limits[1], num_bins + 1) histo = np.histogram(data, bin_edges, normed=True) print("PLOT LIMITS:", limits) # print 'DATA:', data # print 'BIN HEIGHT', histo[0] plot = Plot(*view_utils.get_figure(new_fig=True, subplot=111)) view_utils.plot_limits(plot.fig, plot.ax, xlim=limits, no_ylim=True) plot.ax.bar(histo[1][:-1], histo[0], width=bin_widths(histo[1])) dp, bc = dist_points(histo[1], dist) # print 'BIN CENTERS:', bc, len(bc) if dp is not None: # print 'DIST POINTS:', dp, len(dp) plot.ax.plot(bc, dp, "r*") plot.ax.set_title("%s (%s)" % (feat, typ)) _plots.append(plot) return _plots