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 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 __init__(self, *args, **kw): BaseInset.__init__(self, *args, **kw) ScatterPlot.__init__(self) self.border_visible = kw.get('border_visible', True) self.marker = 'circle' # self.color = 'red' self.marker_size = 1.5 if not self.visible_axes: self.x_axis.visible = False self.y_axis.visible = False # self.set_limits() nsigma = 1 orientation = 'x' line_width = 1 visible = True ebo = ErrorBarOverlay(component=self, orientation=orientation, nsigma=nsigma, line_width=line_width, use_end_caps=False, visible=visible) self.overlays.append(ebo)
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 __init__(self, *args, **kw): ScatterPlot.__init__(self) BaseInset.__init__(self, *args, **kw) self.border_visible = kw.get('border_visible', True) self.marker = 'circle' # self.color = 'red' # self.marker_size = 1.5 if not self.visible_axes: self.x_axis.visible = False self.y_axis.visible = False
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