obspy情节流是一个具有不同颜色的情节

发布于 2025-02-08 06:31:24 字数 228 浏览 2 评论 0原文

嗨,我是新手使用obspy。

我想将两个流绘制到一个图。

我制作了下面的代码。

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

我成功地绘制了两个图,但是我想做的就是将它们绘制为两种颜色。

当我放置“颜色”选项时,两种颜色都会更改。

我如何设置颜色?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

表情可笑 2025-02-15 06:31:25

当前,不可能更改单个波形的颜色,并且更改颜色将会更改所有 toveforms。我建议您使用matplotlib从obspy流制作自己的图表:

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()

“带有不同颜色的波形示例”“具有不同颜色的示例”>

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文