diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-06-18 22:58:03 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2014-06-18 22:58:03 +0200 |
commit | 57cc955807e31b17659000df56cf7e7d7d1a2ba6 (patch) | |
tree | 04af56d103e4cfea2b605c4103e3bf83ab1fdc9c | |
parent | 613e69236f00f7bff184743953e673f71d11b68f (diff) | |
download | scripts-57cc955807e31b17659000df56cf7e7d7d1a2ba6.tar.gz |
interrupts-graph.py: conditionally update domain
Do not update domain if looking at a previous part, or if the new line
fits in the current graph. This makes it easier to look at older data
while updating the plot.
-rwxr-xr-x | rare/interrupts-graph.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/rare/interrupts-graph.py b/rare/interrupts-graph.py index 76006cd..1a26cce 100755 --- a/rare/interrupts-graph.py +++ b/rare/interrupts-graph.py @@ -234,10 +234,11 @@ def refresh_data(): return updated smooth = {} +last_min_x = 0 @synchronized(data_lock) def update(): """Reads new data and updates the line values.""" - global update_legend + global update_legend, last_min_x # Update lines for name in names: ys = yvalues[name] @@ -298,7 +299,13 @@ def update(): # The first XRANGE items fit in the screen min_x = max(start_time - XRANGE, 0) - plt.xlim(min_x, min_x + XRANGE) + cur_min_x, _ = plt.xlim() + # If the current range is equal or further than the previously recorded + # range, consider it sticky and update the xlim with the new range. + if cur_min_x >= last_min_x: + last_min_x = min_x + if cur_min_x <= min_x: + plt.xlim(min_x, min_x + XRANGE) def do_draw(): """Actually draw the graph, updating the legend if necessary.""" |