def test_scatter_plot(self): x = np.linspace(0.0, 1.0, 5) sp = ScatterPlot() with warnings.catch_warnings(record=True) as w: sp._cached_selected_pts = None sp._cached_selected_pts = np.column_stack([x, x]) self.assertEqual(w, [])
def get_variable_size_scatter_plot(): boston = datasets.load_boston() prices = boston['target'] lower_status = boston['data'][:, -1] tax = boston['data'][:, 9] x, y = get_data_sources(x=lower_status, y=prices) x_mapper, y_mapper = get_mappers(x, y) # normalize between 0 and 10 marker_size = tax / tax.max() * 10. scatter_plot = ScatterPlot(index=x, value=y, index_mapper=x_mapper, value_mapper=y_mapper, marker='circle', marker_size=marker_size, title='Size represents property-tax rate', **PLOT_DEFAULTS) scatter_plot.color = (0.0, 1.0, 0.3, 0.4) add_axes(scatter_plot, x_label='Percent lower status in the population', y_label='Median house prices') return scatter_plot
def get_scatter_plot(): boston = datasets.load_boston() prices = boston['target'] lower_status = boston['data'][:,-1] x, y = get_data_sources(x=lower_status, y=prices) x_mapper, y_mapper = get_mappers(x, y) scatter_plot = ScatterPlot( index=x, value=y, index_mapper=x_mapper, value_mapper=y_mapper, marker='circle', **PLOT_DEFAULTS ) scatter_plot.line_width = 1.0 add_axes(scatter_plot, x_label='Percent lower status in the population', y_label='Median house prices') return scatter_plot