Skip to content

Commit a23781c

Browse files
committed
MDS: No shapes and colors by row/col names; ignore axis
1 parent 44339fe commit a23781c

File tree

1 file changed

+11
-31
lines changed

1 file changed

+11
-31
lines changed

Orange/widgets/unsupervised/owmds.py

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -448,15 +448,14 @@ def _clear_plot(self):
448448

449449
def update_controls(self):
450450
if self.data is None:
451-
if getattr(self.matrix, 'axis', 1) == 0:
452-
# Column-wise distances
453-
attr = "Attribute names"
454-
self.labelvar_model[:] = ["No labels", attr]
455-
self.shapevar_model[:] = ["Same shape", attr]
456-
self.colorvar_model[:] = ["Same color", attr]
457-
458-
self.color_value = attr
459-
self.shape_value = attr
451+
axis = getattr(self.matrix, 'axis', 1)
452+
attr = ["Column labels", "Row labels"][axis]
453+
self.labelvar_model[:] = ["No labels", attr]
454+
self.shapevar_model[:] = ["Same shape"]
455+
self.colorvar_model[:] = ["Same color"]
456+
457+
self.color_value = "Same color"
458+
self.shape_value = "Same shape"
460459
else:
461460
domain = self.data.domain
462461
all_vars = list(filter_visible(domain.variables + domain.metas))
@@ -802,18 +801,6 @@ def jitter(x, factor=1, rstate=None):
802801
)
803802
pen_data = Mdsplotutils.pen_data(color_data * 0.8, pointflags)
804803
brush_data = Mdsplotutils.brush_data(color_data)
805-
elif have_matrix_transposed and \
806-
self.colorvar_model[color_index] == 'Attribute names':
807-
attr = attributes(self.matrix)
808-
palette = colorpalette.ColorPaletteGenerator(len(attr))
809-
color_data = [palette.getRGB(i) for i in range(len(attr))]
810-
color_data = numpy.hstack((
811-
color_data,
812-
numpy.full((len(color_data), 1), self.symbol_opacity,
813-
dtype=float))
814-
)
815-
pen_data = Mdsplotutils.pen_data(color_data * 0.8, pointflags)
816-
brush_data = Mdsplotutils.brush_data(color_data)
817804
else:
818805
pen_data = make_pen(QColor(Qt.darkGray), cosmetic=True)
819806
if self._selection_mask is not None:
@@ -846,13 +833,6 @@ def jitter(x, factor=1, rstate=None):
846833
data = data % (len(Symbols) - 1)
847834
data[numpy.isnan(data)] = len(Symbols) - 1
848835
shape_data = symbols[data.astype(int)]
849-
elif have_matrix_transposed and \
850-
self.shapevar_model[shape_index] == 'Attribute names':
851-
Symbols = ScatterPlotItem.Symbols
852-
symbols = numpy.array(list(Symbols.keys()))
853-
attr = [i % (len(Symbols) - 1)
854-
for i, _ in enumerate(attributes(self.matrix))]
855-
shape_data = symbols[attr]
856836
else:
857837
shape_data = "o"
858838
self._shape_data = shape_data
@@ -884,10 +864,10 @@ def jitter(x, factor=1, rstate=None):
884864
label_data = [label_var.str_val(val) for val in label_data]
885865
label_items = [pg.TextItem(text, anchor=(0.5, 0), color=0.0)
886866
for text in label_data]
887-
elif have_matrix_transposed and \
888-
self.labelvar_model[label_index] == 'Attribute names':
867+
elif self.matrix is not None and label_index:
889868
attr = attributes(self.matrix)
890-
label_items = [pg.TextItem(str(text), anchor=(0.5, 0))
869+
label_items = [pg.TextItem(str(text), anchor=(0.5, 0),
870+
color=0.0)
891871
for text in attr]
892872
else:
893873
label_items = None

0 commit comments

Comments
 (0)