stream plot section: st.plot(type='section')

Dear All,

Having three issues with stream plot st.plot(type=‘section’) in FC20 linux, with obspy0.9.2

import obspy
print obspy.version

  1. The traces are assumed to have the same start time. (There is no relative shifting between traces, as in plot(type=‘normal’). Easy to handle if known, but If this is a feature, not a bug, it would be good to state this in the docs?

  2. scaling/normalization: in plot(type=‘normal’) the parameter is equal_scale. equal_scale works fine, but In plot(type=‘section’) the parameter is norm. (Why not use equal_scale in section?) But I can’t get norm to do anything, despite:

def __sectNormalizeTraces(self):
This helper function normalizes the traces
self._tr_normfac = np.ones(self._tr_num)
if self.sect_norm_method == ‘trace’:

Normalize against each traces’ maximum

for tr in range(self._tr_num):
self._tr_normfac[tr] = np.abs(self._tr_data[tr]).max()
elif self.sect_norm_method == ‘stream’:

Normalize the whole stream

msg = ‘Define a normalisation method. Valid normalisations’ +
‘are ‘trace’, ‘stream’. See documentation.’
raise ValueError(msg)

self._plot_init = False

but given the fact that I don’t get msg even if I say:

plot(type=‘section’, norm=‘bla’)

makes me think that it is not used at all. I don’t understand this because it appears to be called here:

def plotSection(self, *args, **kwargs):
Plots multiple waveforms as a record section on a single plot.

Initialise data and plot




def __sectInitPlot(self):
Function initialises plot all the illustration is done by
ax = self.fig.gca()

Calculate normalizing factor


Calculate scaling factor


ax.plot() prefered over containers

for _tr in range(self._tr_num):

Scale, normalize and shift traces by offset

for plotting

ax.plot(self._tr_data[_tr] / self._tr_normfac[_tr]

  • (1. / self._sect_scale)
  • self._tr_offsets_norm[_tr],
    self._sect_plot_init = True

Can ‘section’ use the same scheme as in type=‘normal’, where equal_scale does work?

  1. Finally, I don’t know why, but in type=‘section’, you need a bandpass of sorts. At least in my example, AND in the one on the gallery waveform_plotting_tutorial_6:

without the filter:

#st.filter(‘bandpass’, freqmin=0.1, freqmax=10)

I get the following error when using st.plot(type=‘section’) by running python “”:

Traceback (most recent call last):
File “”, line 1, in
File “/home/kasper/Downloads/”, line 32, in
time_down=True, linewidth=.25, grid_linewidth=.25)
File “/usr/lib/python2.7/site-packages/obspy-0.9.2-py2.7-linux-x86_64.egg/obspy/core/”, line 1058, in plot
return waveform.plotWaveform(*args, **kwargs)
File “/usr/lib/python2.7/site-packages/obspy-0.9.2-py2.7-linux-x86_64.egg/obspy/imaging/”, line 253, in plotWaveform
self.plotSection(*args, **kwargs)
File “/usr/lib/python2.7/site-packages/obspy-0.9.2-py2.7-linux-x86_64.egg/obspy/imaging/”, line 1114, in plotSection
File “/usr/lib/python2.7/site-packages/obspy-0.9.2-py2.7-linux-x86_64.egg/obspy/imaging/”, line 1229, in __sectInitTraces[_tr].data, self.max_npts)
File “/usr/lib64/python2.7/site-packages/scipy/signal/”, line 1292, in resample
X = fft(x, axis=axis)
File “/usr/lib64/python2.7/site-packages/scipy/fftpack/”, line 222, in fft
raise ValueError(“type %s is not supported” % tmp.dtype)
ValueError: type >f4 is not supported

Why is there an fft involved in plotting traces in a section? There doesn’t seem to be one in st.plot(type=‘normal’), which runs with and without the bandpass filter…

Thanks for your help,

Hi Kasper,

this appears to be a bit more complex so I opened an issue on GitHub to be able to track it easier:

Thanks for your report and all the best!


Hi Kasper,

for customized plots it's probably better/faster to build up the plot
using matplotlib from scratch. There's pretty good support also for
having timestamps on one axis.

See this mail from march for a start..


Thanks, Lion and Tobias:

I understand – and agree – that for full control and flexibility in plotting we should write custom scripts using matplotlib. (I do this for research purposes.) However, for teaching students new to python and obspy it would be nice for “type=‘section’” to handle what I think are the basics, the way you intended. I will continue to look at these issues too.

Thanks again for all your hard work on this!