0

Hi I am new to use obspy.

I want to plot two streams to one plot.

I made code as below.

st1=read('/path/1.SAC')
st1+=read('/path/2.SAC')
st1.plot()

I succeed to plot two plots but what I want to do is plotting them as two colors.

When I put the option of 'color', then both colors are changed.

How can I set colors seperately?

Joe
  • 51
  • 7

1 Answers1

0

Currently it is not possible to change the color of individual waveforms, and changing color will change all waveforms as you mentioned. I suggest you make your own graph from the ObsPy Stream using Matplotlib:

from obspy import read
import matplotlib.dates as mdates
import matplotlib.pyplot as plt

st1=read('/path/1.SAC')
st1+=read('/path/2.SAC')

# Start figure
fig, ax = plt.subplots(nrows=2, sharex='col')
ax[0].plot(st1[0].times("matplotlib"), st1[0].data, color='red')
ax[1].plot(st1[1].times("matplotlib"), st1[1].data, color='blue')

# Format xaxis
xfmt_day = mdates.DateFormatter('%H:%M')
ax[0].xaxis.set_major_formatter(xfmt_day)
ax[0].xaxis.set_major_locator(mdates.MinuteLocator(interval=1))

plt.show()

Example of waveform plot with different colors

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77