1

I'm required to use the information from a .sac file and plot it against a grid. I know that using various ObsPy functions one is able to plot the Seismograms using st.plot() but I can't seem to get it against a grid. I've also tried following the example given here "How do I draw a grid onto a plot in Python?" but have trouble when trying to configure my x axis to use UTCDatetime. I'm new to python and programming of this sort so any advice / help would be greatly appreciated.

Various resources used: "http://docs.obspy.org/tutorial/code_snippets/reading_seismograms.html"

"http://docs.obspy.org/packages/autogen/obspy.core.stream.Stream.plot.html#obspy.core.stream.Stream.plot"

4

1 回答 1

1

' Streamsplot()方法实际上会自动生成一个网格,例如,如果您采用默认示例并通过以下方式绘制它:

from obspy.core import read
st = read()  # without filename an example file is loaded
tr = st[0]   # we will use only the first channel
tr.plot()

在此处输入图像描述

您可能想要使用http://docs.obspy.org/packages/autogen/obspy.core.stream.Stream.plot.html中指出的number_of_ticks,tick_format和参数。tick_rotation

但是,如果您想要更多控制,您可以将matplotlib图形作为输入参数传递给该plot()方法:

from obspy.core import read
import matplotlib.pyplot as plt

fig = plt.figure()

st = read('/path/to/file.sac')
st.plot(fig=fig)

# at this point do whatever you want with your figure, e.g.
fig.gca().set_axis_off()

# finally display your figure
fig.show()

希望能帮助到你。

于 2013-09-02T00:07:54.390 回答