Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
color_data_sel, brush_data_sel = self.compute_colors_sel()
size_data = self.compute_sizes()
shape_data = self.compute_symbols()
if self.should_draw_density():
rgb_data = [pen.color().getRgb()[:3] for pen in color_data]
self.density_img = classdensity.class_density_image(
min_x, max_x, min_y, max_y, self.resolution, x_data, y_data, rgb_data
)
self.plot_widget.addItem(self.density_img)
self.data_indices = np.flatnonzero(self.valid_data)
if len(self.data_indices) != len(self.data):
self.master.Information.missing_coords(self.shown_x.name, self.shown_y.name)
self.scatterplot_item = ScatterPlotItem(
x=x_data,
y=y_data,
data=self.data_indices,
symbol=shape_data,
size=size_data,
pen=color_data,
brush=brush_data,
)
self.scatterplot_item_sel = ScatterPlotItem(
x=x_data,
y=y_data,
data=self.data_indices,
symbol=shape_data,
size=size_data + SELECTION_WIDTH,
pen=color_data_sel,
brush=brush_data_sel,
def make_shape_legend(self):
if self.attr_shape is None or self.attr_shape == self.get_color():
return
if not self.legend:
self.create_legend()
color = QColor(0, 0, 0)
color.setAlpha(self.alpha_value)
for i, value in enumerate(self._get_values(self.attr_shape)):
self.legend.addItem(
ScatterPlotItem(
pen=color, brush=color, size=10, symbol=self.CurveSymbols[i]
),
escape(value),
)
self.plot_widget.addItem(self.density_img)
self.data_indices = np.flatnonzero(self.valid_data)
if len(self.data_indices) != len(self.data):
self.master.Information.missing_coords(self.shown_x.name, self.shown_y.name)
self.scatterplot_item = ScatterPlotItem(
x=x_data,
y=y_data,
data=self.data_indices,
symbol=shape_data,
size=size_data,
pen=color_data,
brush=brush_data,
)
self.scatterplot_item_sel = ScatterPlotItem(
x=x_data,
y=y_data,
data=self.data_indices,
symbol=shape_data,
size=size_data + SELECTION_WIDTH,
pen=color_data_sel,
brush=brush_data_sel,
)
self.plot_widget.addItem(self.scatterplot_item_sel)
self.plot_widget.addItem(self.scatterplot_item)
self.scatterplot_item.selected_points = []
self.scatterplot_item.sigClicked.connect(self.select_by_click)
self.draw_regression_line(x_data, y_data, min_x, max_x)
self.update_labels()
def make_color_legend(self):
if self.attr_color is None:
return
use_shape = self.attr_shape == self.get_color()
if self.attr_color.is_discrete:
if not self.legend:
self.create_legend()
palette = self.discrete_palette
for i, value in enumerate(self._get_values(self.attr_color)):
color = QColor(*palette.getRGB(i))
pen = _make_pen(color.darker(self.DarkerValue), 1.5)
color.setAlpha(self.alpha_value if self.subset_indices is None else 255)
brush = QBrush(color)
self.legend.addItem(
ScatterPlotItem(
pen=pen,
brush=brush,
size=10,
symbol=self.CurveSymbols[i] if use_shape else "o",
),
escape(value),
)
else:
legend = self.color_legend = LegendItem()
legend.setParentItem(self.plot_widget.getViewBox())
legend.restoreAnchor(self.__color_legend_anchor)
label = PaletteItemSample(self.continuous_palette, self.scale)
legend.addItem(label, "")
legend.setGeometry(label.boundingRect())