summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-06-19 01:09:59 +0200
committerPeter Wu <peter@lekensteyn.nl>2014-06-19 01:09:59 +0200
commit5df0397960b00b7d82c098204aa52577dbc17046 (patch)
treedfdfb8e8e321076a2688852bb372ceef3ddb9edc
parent57cc955807e31b17659000df56cf7e7d7d1a2ba6 (diff)
downloadscripts-5df0397960b00b7d82c098204aa52577dbc17046.tar.gz
interrupts-graph.py: make selection larger
Just changing the marker does not make selections more apparent. Increase line thickness and zorder to increase visibility.
-rwxr-xr-xrare/interrupts-graph.py44
1 files changed, 32 insertions, 12 deletions
diff --git a/rare/interrupts-graph.py b/rare/interrupts-graph.py
index 1a26cce..8158c4f 100755
--- a/rare/interrupts-graph.py
+++ b/rare/interrupts-graph.py
@@ -163,6 +163,8 @@ if LOG_SCALE_BASE > 0:
# Used when picking a new line or in update()
update_legend = False
+# Lines depicting interrupts changes (the "real" markers and smoothed lines)
+lines, smooth_lines = {}, {}
### BEGIN EVENTS
# After pressing ^W, stop the main loop
@@ -181,16 +183,31 @@ def on_keypress(event):
update_title()
plt.connect('key_press_event', on_keypress)
-last_selected = None
+last_selected, last_smooth = None, None
+lines_lock = threading.Lock()
+@synchronized(lines_lock)
def select_line(line):
- global last_selected
- line = lines[line.get_label()]
+ global last_selected, last_smooth
+ # HACK: needed to support selection of legend items
+ name = line.get_label()
+ line = lines[name]
if last_selected:
last_selected.set_marker(MARKER_DEFAULT)
+ for someline in (last_selected, last_smooth):
+ if someline:
+ someline.set_linewidth(someline.get_linewidth() / 4)
+ someline.set_zorder(someline.get_zorder() - 1)
if last_selected == line:
+ # Same line selected again. Clicking acts as a toggle, so do not mark
+ # the same line again.
last_selected = None
else:
line.set_marker(MARKER_SELECTED)
+ last_smooth = smooth_lines[name] if name in smooth_lines else None
+ for someline in (line, last_smooth):
+ if someline:
+ someline.set_linewidth(someline.get_linewidth() * 4)
+ someline.set_zorder(someline.get_zorder() + 1)
last_selected = line
def on_pick(event):
@@ -210,7 +227,6 @@ yvalues = {}
for name in names:
ydata = deque([], x_entries_max)
yvalues[name] = ydata
-lines = {}
def update_title():
title = input_filename
@@ -233,8 +249,8 @@ def refresh_data():
start_time += INTERVAL
return updated
-smooth = {}
last_min_x = 0
+@synchronized(lines_lock)
@synchronized(data_lock)
def update():
"""Reads new data and updates the line values."""
@@ -269,15 +285,19 @@ def update():
#ynew = spline(xdata, ydata, xnew)
# quadratic and cubic splines give too much deviations
ynew = interp1d(xdata, ydata, kind='slinear')(xnew)
- if not name in smooth:
- smooth[name], = plt.plot(xnew, ynew, color=lines[name].get_color())
+ if not name in smooth_lines:
+ line = lines[name]
+ smooth_lines[name], = plt.plot(xnew, ynew,
+ linewidth=line.get_linewidth(),
+ zorder=line.get_zorder(),
+ color=line.get_color())
# Smooth line is shown, hide straight lines
- lines[name].set_linestyle('')
+ line.set_linestyle('')
else:
- smooth[name].set_data(xnew, ynew)
- elif name in smooth:
- smooth[name].remove()
- del smooth[name]
+ smooth_lines[name].set_data(xnew, ynew)
+ elif name in smooth_lines:
+ smooth_lines[name].remove()
+ del smooth_lines[name]
# No smooth line is shown, fallback to straight lines
lines[name].set_linestyle('-')
elif name in lines: