diff --git a/gwinc/plot.py b/gwinc/plot.py
index 696d95e83cc2be13611a320007cdd75d4a0565e7..07ec4387d2c6ffc3e5740aa199fd22dcb601e101 100644
--- a/gwinc/plot.py
+++ b/gwinc/plot.py
@@ -21,6 +21,8 @@ def plot_noise(
     else:
         fig = ax.figure
 
+    ylim = kwargs.get('ylim')
+
     for name, trace in traces.items():
         try:
             data, style = trace
@@ -58,9 +60,7 @@ def plot_noise(
     )
 
     ax.autoscale(enable=True, axis='y', tight=True)
-    if 'ylim' in kwargs:
-        ax.set_ylim(kwargs['ylim'])
-    else:
+    if ylim:
         ax.set_ylim(ylim)
     ax.set_xlim(freq[0], freq[-1])