vibration_analyze: Only highlight the frequency range if we have a config
[calibcant.git] / calibcant / vibration_analyze.py
index 9d2fa29b0d402ea8e4b03856eb9f1fb8f9c0b6f0..487d027ce88509185b2432c5fdc7001231b807cd 100644 (file)
@@ -536,12 +536,13 @@ def plot(deflection=None, freq_axis=None, power=None, A=None, B=None,
         freq_axes.autoscale(tight=True)
         xmin,xmax = freq_axes.get_xbound()
         ymin,ymax = freq_axes.get_ybound()
-    
+
         # highlight the region we're fitting
-        freq_axes.axvspan(
-            config['minimum-fit-frequency'],
-            config['maximum-fit-frequency'],
-            facecolor='g', alpha=0.1, zorder=-2)
+        if config:
+            freq_axes.axvspan(
+                config['minimum-fit-frequency'],
+                config['maximum-fit-frequency'],
+                facecolor='g', alpha=0.1, zorder=-2)
 
         if A is not None:
             fitdata = breit_wigner(freq_axis, A, B, C, D)