Dear obspy-ers
I was wondering whether we could plot all traces in a stream on one
plot. I would like to have traces contained in a stream plotted in one
section.
Thank you in advance for any suggestion and help
BR,
Makky
Dear obspy-ers
I was wondering whether we could plot all traces in a stream on one
plot. I would like to have traces contained in a stream plotted in one
section.
Thank you in advance for any suggestion and help
BR,
Makky
Dear Makky,
did you try to use the parameter automerge=True ?
See
http://docs.obspy.org/master/packages/autogen/obspy.core.stream.Stream.plot.html#obspy.core.stream.Stream.plot
for details.
If you want to plot several traces of different seed ids in one axes
its probably better to create your own custom matplolib plot. A very
basic one:
import pylab as plt
imort numpy as np
for tr in stream:
plt.plot(np.arange(len(tr)), tr.data)
plt.show()
Hope it helps,
Tom
To follow up with some basic plotting tips:
- if you want time stamps on y axes try something like..
import matplotlib.pyplot as plt
from matplotlib.dates import date2num
start = date2num(tr.stats.starttime)
end = date2num(tr.stats.endtime)
times = np.linspace(start, end, tr.stats.npts)
plt.plot_date(times, tr.data, "r-")
- another helper function on figure objects is helpful
fig = plt.figure()
# plotting here
fig.autofmt_xdate()
- one more thing: you actually *can* maybe use obspy's preview plot to
plot several different channels on top of each (i did a simple plot
like this some days ago) other but you might run into limitations
pretty fast.. (e.g. all follow up plots need to have same number of
subplots)
from obspy import read
import matplotlib.pyplot as plt
st = read()
fig = plt.figure()
for comp, color in zip(["N", "Z"], ["r", "k"]):
st_ = st.select(component=comp)
st_.plot(show=False, fig=fig, color=color,
type="relative")
plt.title("My own title")
plt.show()
best,
Tobias
P.S.: Maybe somebody should add some basic tips for matplotlib ploting
in the tutorial plotting section after the preview plot examples..
Dear Makky,
did you try to use the parameter automerge=True ? See
obspy.core.stream.Stream.plot — ObsPy 1.4.0.post0+326.gdfb021350c.obspy.master documentation
for details.