peus-plot: optionally give x-range as 2nd argument

Change-Id: I445ef00487fc34343f5a0333643f61753a1c4948
This commit is contained in:
zolliker 2025-04-02 14:56:05 +02:00
parent 75783b211a
commit 343ce90321
2 changed files with 7 additions and 3 deletions

View File

@ -25,13 +25,16 @@ t_rois = get_modules('roi%d')
i_rois = get_modules('roi%di')
q_rois = get_modules('roi%dq')
maxx = None
if len(sys.argv) > 1:
maxy = float(sys.argv[1])
if len(sys.argv) > 2:
maxx = float(sys.argv[2])
else:
maxy = 0.02
iqplot = Plot(maxy)
iqplot = Plot(maxy, maxx)
for i in range(99):
pass

View File

@ -70,9 +70,10 @@ def rects(intervals, y12):
class Plot:
def __init__(self, maxy):
def __init__(self, maxy, maxx=None):
self.lines = {}
self.yaxis = ((-2 * maxy, maxy), (-maxy, 2 * maxy))
self.maxx = maxx
self.first = True
self.fig = None
@ -124,7 +125,7 @@ class Plot:
self.fig, axleft = plt.subplots(figsize=(15,7))
self.pause = Pause(self.fig)
plt.title("I/Q", fontsize=14)
axleft.set_xlim(0, curves[0][-1])
axleft.set_xlim(0, self.maxx or curves[0][-1])
self.ax = [axleft, axleft.twinx()]
self.ax[0].axhline(y=0, color='#cccccc') # show x-axis line
self.ax[1].axhline(y=0, color='#cccccc')