Skip to content

Commit 1e367a2

Browse files
committed
fixes #264
1 parent 6470928 commit 1e367a2

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Change History
66

77
:1.1.16: expected by *tba* :
88

9+
* `#264 <https://github.com/prjemian/spec2nexus/issues/264>`_
10+
Limit number of traces shown on a plot - use a FIFO
11+
912
:1.1.15: expected by *2019-11-21* : bug fixes, adds asyn record support
1013

1114
* `#259 <https://github.com/prjemian/spec2nexus/issues/259>`_

apstools/utils.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
.. autosummary::
55
6+
~becplot_prune_fifo
67
~cleanupText
78
~command_list_as_table
89
~connect_pvlist
@@ -76,6 +77,45 @@
7677
class ExcelReadError(xlrd.XLRDError): ...
7778

7879

80+
def becplot_prune_fifo(n, y, x):
81+
"""
82+
find the plot with axes x and y and replot with only the last *n* lines
83+
84+
Note: this is not a bluesky plan. Call it as normal Python function.
85+
86+
EXAMPLE::
87+
88+
becplot_prune_fifo(1, noisy, m1)
89+
90+
PARAMETERS
91+
92+
n : int
93+
number of plots to keep
94+
95+
y : object
96+
ophyd Signal object on dependent (y) axis
97+
98+
x : object
99+
ophyd Signal object on independent (x) axis
100+
101+
Assumes object `bec` (instance of BestEffortCallback) is defined.
102+
"""
103+
global bec
104+
for liveplot in bec._live_plots.values():
105+
lp = liveplot.get(y.name)
106+
if lp is None:
107+
logging.debug(f"no LivePlot with name {y.name}")
108+
continue
109+
if lp.x != x.name or lp.y != y.name:
110+
logging.debug(f"no LivePlot with axes ('{x.name}', '{y.name}')")
111+
continue
112+
if len(lp.ax.lines) > n:
113+
logging.debug(f"limiting LivePlot({y.name}) to {n} traces")
114+
lp.ax.lines = lp.ax.lines[-n:]
115+
lp.update_plot()
116+
117+
118+
79119
def cleanupText(text):
80120
"""
81121
convert text so it can be used as a dictionary key

0 commit comments

Comments
 (0)