Skip to content

Commit

Permalink
Slider graph: Allow setting widths
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Jul 5, 2021
1 parent 7a8b69b commit 6c6b67a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Orange/widgets/utils/slidergraph.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from itertools import repeat, chain
from numbers import Number

import numpy as np
from pyqtgraph import PlotWidget, mkPen, InfiniteLine, PlotCurveItem, \
TextItem, Point
Expand Down Expand Up @@ -51,7 +54,7 @@ def __init__(self, x_axis_label, y_axis_label, callback):
self.data_increasing = None # true if data mainly increasing

def update(self, x, y, colors, cutpoint_x=None, selection_limit=None,
names=None):
names=None, *, widths=()):
"""
Function replots a graph.
Expand All @@ -76,7 +79,12 @@ def update(self, x, y, colors, cutpoint_x=None, selection_limit=None,
"""
self.clear_plot()
if names is None:
names = [None] * len(y)
names = ()
names = chain(names, repeat(None))
if isinstance(widths, Number):
widths = repeat(widths)
else:
widths = chain(widths, repeat)

self.sequences = y
self.x = x
Expand All @@ -85,9 +93,10 @@ def update(self, x, y, colors, cutpoint_x=None, selection_limit=None,
self.data_increasing = [np.sum(d[1:] - d[:-1]) > 0 for d in y]

# plot sequence
for s, c, n, inc in zip(y, colors, names, self.data_increasing):
for s, c, n, inc, w in zip(
y, colors, names, self.data_increasing, widths):
c = QColor(c)
self.plot(x, s, pen=mkPen(c, width=2), antialias=True)
self.plot(x, s, pen=mkPen(c, width=w), antialias=True)

if n is not None:
label = TextItem(
Expand Down

0 comments on commit 6c6b67a

Please sign in to comment.