11. Plotting Spectrograms

The following lines of code demonstrate how to make a spectrogram plot of an ObsPy Stream object.

Lots of options can be customized, see spectrogram() for more details. For example, the colormap of the plot can easily be adjusted by importing a predefined colormap from matplotlib.cm, nice overviews of available matplotlib colormaps are given at:

import obspy

st = obspy.read("https://examples.obspy.org/RJOB_061005_072159.ehz.new")
st.spectrogram(log=True, title='BW.RJOB ' + str(st[0].stats.starttime))

(Source code, png, hires.png)