diff --git a/src/python_spectrometer/_plot_manager.py b/src/python_spectrometer/_plot_manager.py
index e29107d35159f6bddc1842595c5fa1cc73aedcd4..66dc36b6525a2bf5731b8483037314bc068d284c 100644
--- a/src/python_spectrometer/_plot_manager.py
+++ b/src/python_spectrometer/_plot_manager.py
@@ -694,8 +694,8 @@ class PlotManager:
                     ydata = self.lines[key][plot][line]['line'].get_ydata()[
                         (left <= xdata) & (xdata <= right)
                     ]
-                    top = max(top, ydata.max())
-                    bottom = min(bottom, ydata.min())
+                    top = max(top, np.nanmax(ydata))
+                    bottom = min(bottom, np.nanmin(ydata))
                 # Transform to correct scale
                 transform = self.axes[plot][line].transScale
                 top, bottom = transform.transform([(1, top),