Skip to content

Commit

Permalink
Bar Plot: Separate groups
Browse files Browse the repository at this point in the history
  • Loading branch information
VesnaT committed Mar 1, 2021
1 parent d1d9fe3 commit 6e90728
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Orange/widgets/visualize/owbarplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def legend_items(self):

class BarPlotGraph(pg.PlotWidget):
selection_changed = Signal(list)
bar_width = 0.8
bar_width = 0.7

def __init__(self, master, parent=None):
self.selection = []
Expand Down Expand Up @@ -203,6 +203,7 @@ def reset_graph(self):
self.clear()
self.update_bars()
self.update_axes()
self.update_group_lines()
self.update_legend()
self.reset_view()

Expand Down Expand Up @@ -280,6 +281,20 @@ def select_button_clicked(self):
def reset_button_clicked(self):
self.reset_view()

def update_group_lines(self):
if self.bar_item is None:
return

labels = np.array(self.master.get_group_labels())
if labels is None or len(labels) == 0:
return

_, indices = np.unique(labels, return_index=True)
offset = self.bar_width / 2 + (1 - self.bar_width) / 2
for index in sorted(indices)[1:]:
line = pg.InfiniteLine(pos=index - offset, angle=90)
self.addItem(line)

def select_by_rectangle(self, rect: QRectF):
if self.bar_item is None:
return
Expand Down

0 comments on commit 6e90728

Please sign in to comment.