Plot record section offset in meters instead of km

Hi All,
Is there a way to plot offset in meters instead of km when using
st.plot(type="section")

Thank you!
Januka

There’s no built in switch I think, so you’d have to work around it a bit. There’s multiple ways…

First of all you need to work on the matplotlib objects after the plot command some, so…

fig = st.plot(..., handle=True, show=False)

If you don’t need the plot to be interactive, you could just change the tick labels in the figure after the obspy plot command. Something like…

labels = fig.axes[0].get_xticklabels()
[...]
fig.axes[0].set_xticklabels(new_labels)

…and also change the xlabel accordingly.

Or you could multiply the offsets you input for each trace with 1000 so that effectively after the internal division by 1000 (to go to km) you still end up in units of meters in the plot, but you would still need to change the x axis label kind of like above…

fig.axes[0].set_xlabel("Offset [m]")

Thanks Tobias. handle=True wasn’t obvious. I can work around using your suggestions now.

1 Like