Repository: obspy/obspy

Issue:
PPSD.plot: argument xaxis_frequency does not affect argument period_lim
I scanned through Issue results when searching for 'PPSD' and did not see a similar issue, so my apologies if I missed it. 

According to the [docs](https://docs.obspy.org/packages/autogen/obspy.signal.spectral_estimation.PPSD.plot.html), when 'xaxis_frequency' is set to True, 'period_lim' should be expecting a tuple containing the frequency range in Hz as opposed to a tuple containing a period range. I am not finding this to be the case. If what I am finding is true, either the docs should be updated or some code should be changed.

This is not a regression that I am aware of.

Thanks for your time!

ObsPy version: 1.1.0
Python version: Python 3.6.6
Platform: Linux
ObsPy installed from Anaconda

Example:
```python
from obspy.clients.fdsn.client import Client
from obspy import UTCDateTime
from obspy import read
from obspy.signal import PPSD

client = Client("IRIS")

starttime = UTCDateTime('2018-09-18')
endtime = UTCDateTime('2018-09-19')
inventory = client.get_stations(network='PE', station='PAPL',
            starttime=starttime, endtime=endtime, level='response')

tr = read('waveforms/PE.PAPL..HHZ__20180918T000000Z__20180919T000000Z.mseed')
tr = tr.select()[0] 

ppsd = PPSD(tr.stats, metadata=inventory)
ppsd.add(tr)
ppsd.plot(xaxis_frequency=True, period_lim=(1.0, 5.0)
```


Discussion:

Resolving patch:
diff --git a/obspy/signal/spectral_estimation.py b/obspy/signal/spectral_estimation.py
--- a/obspy/signal/spectral_estimation.py
+++ b/obspy/signal/spectral_estimation.py
@@ -1841,13 +1841,11 @@ def plot(self, filename=None, show_coverage=True, show_histogram=True,
 
         ax.semilogx()
         if xaxis_frequency:
-            xlim = map(lambda x: 1.0 / x, period_lim)
             ax.set_xlabel('Frequency [Hz]')
             ax.invert_xaxis()
         else:
-            xlim = period_lim
             ax.set_xlabel('Period [s]')
-        ax.set_xlim(sorted(xlim))
+        ax.set_xlim(period_lim)
         ax.set_ylim(self.db_bin_edges[0], self.db_bin_edges[-1])
         if self.special_handling is None:
             ax.set_ylabel('Amplitude [$m^2/s^4/Hz$] [dB]')


Test patch:
diff --git a/obspy/imaging/tests/images/ppsd_freq.png b/obspy/imaging/tests/images/ppsd_freq.png
Binary files a/obspy/imaging/tests/images/ppsd_freq.png and b/obspy/imaging/tests/images/ppsd_freq.png differ
diff --git a/obspy/imaging/tests/test_ppsd.py b/obspy/imaging/tests/test_ppsd.py
--- a/obspy/imaging/tests/test_ppsd.py
+++ b/obspy/imaging/tests/test_ppsd.py
@@ -12,7 +12,7 @@
 import matplotlib.pyplot as plt
 import numpy as np
 
-from obspy.core.util.testing import ImageComparison
+from obspy.core.util.testing import ImageComparison, MATPLOTLIB_VERSION
 from obspy.signal.tests.test_spectral_estimation import _get_ppsd
 
 
@@ -47,9 +47,15 @@ def test_ppsd_plot_frequency(self):
         """
         Test plot of ppsd example data, normal (non-cumulative) style.
         """
+        # mpl < 2.2 has slightly offset ticks/ticklabels, so needs a higher
+        # tolerance (see e.g. http://tests.obspy.org/102260)
+        reltol = 2
+        if MATPLOTLIB_VERSION < [2, 2]:
+            reltol = 4
         # Catch underflow warnings due to plotting on log-scale.
         with np.errstate(all='ignore'):
-            with ImageComparison(self.path, 'ppsd_freq.png', reltol=2.0) as ic:
+            with ImageComparison(self.path, 'ppsd_freq.png',
+                                 reltol=reltol) as ic:
                 self.ppsd.plot(
                     show=False, show_coverage=False, show_histogram=True,
                     show_percentiles=True, percentiles=[20, 40],
diff --git a/obspy/signal/tests/images/ppsd_restricted_stack.png b/obspy/signal/tests/images/ppsd_restricted_stack.png
Binary files a/obspy/signal/tests/images/ppsd_restricted_stack.png and b/obspy/signal/tests/images/ppsd_restricted_stack.png differ
diff --git a/obspy/signal/tests/test_spectral_estimation.py b/obspy/signal/tests/test_spectral_estimation.py
--- a/obspy/signal/tests/test_spectral_estimation.py
+++ b/obspy/signal/tests/test_spectral_estimation.py
@@ -470,11 +470,16 @@ def callback(t_array):
             np.testing.assert_array_equal(selection_got, expected_selection)
 
         # test one particular selection as an image test
+        # mpl < 2.2 has slightly offset ticks/ticklabels, so needs a higher
+        # tolerance (see e.g. http://tests.obspy.org/102260)
+        reltol = 1.5
+        if MATPLOTLIB_VERSION < [2, 2]:
+            reltol = 5
         plot_kwargs = dict(max_percentage=15, xaxis_frequency=True,
                            period_lim=(0.01, 50))
         ppsd.calculate_histogram(**stack_criteria_list[1])
         with ImageComparison(self.path_images,
-                             'ppsd_restricted_stack.png', reltol=1.5) as ic:
+                             'ppsd_restricted_stack.png', reltol=reltol) as ic:
             fig = ppsd.plot(show=False, **plot_kwargs)
             # some matplotlib/Python version combinations lack the left-most
             # tick/label "Jan 2015". Try to circumvent and get the (otherwise
@@ -491,7 +496,7 @@ def callback(t_array):
         #     matches (like above):
         ppsd.calculate_histogram(**stack_criteria_list[1])
         with ImageComparison(self.path_images,
-                             'ppsd_restricted_stack.png', reltol=1.5,
+                             'ppsd_restricted_stack.png', reltol=reltol,
                              plt_close_all_exit=False) as ic:
             fig = ppsd.plot(show=False, **plot_kwargs)
             # some matplotlib/Python version combinations lack the left-most
@@ -527,7 +532,7 @@ def callback(t_array):
         #     image test should pass agin:
         ppsd.calculate_histogram(**stack_criteria_list[1])
         with ImageComparison(self.path_images,
-                             'ppsd_restricted_stack.png', reltol=1.5,
+                             'ppsd_restricted_stack.png', reltol=reltol,
                              plt_close_all_enter=False) as ic:
             ppsd._plot_histogram(fig=fig, draw=True)
             with np.errstate(under='ignore'):