FIX: improper y-limit in Stream/Trace plot when 0-value trace exists#3665
FIX: improper y-limit in Stream/Trace plot when 0-value trace exists#3665Dengda98 wants to merge 3 commits intoobspy:masterfrom
Conversation
|
What happens when you plot equal_scale=False to the plot command? |
|
The plot with equal_scale=False looks fine, probably the default ylim issure only affect this part. obspy/obspy/imaging/waveform.py Lines 822 to 830 in 1b4da27 |
|
@Dengda98 didn't forget you :) Just trying to get my ideas together on how to approach this in the most generalized way (your idea is very valid, trying to think if it could happen e.g. if not "all zeros", but "all the same value", for example, etc?) |
|
@ThomasLecocq Thanks! Bug reproduce (same value) from obspy import *
st = read()
tr2 = st[0].copy()
tr2.data[:] = 1e8 # all the same value, and large enough to cover the normal data
tr2.stats.channel += '2' # just for distinguish
# for tr in st:
# tr.data[:] *= 1e-8
st += Stream(tr2)
st.plot() |
What does this PR do?
Hi ObsPy !
To explain this bug, see the tiny script below,
In this figure, the y-limit of all axes are set to [-0.05, 0.05], which is probably the default margin used by matplotlib when plotting all-zero data. If the range of other traces is smaller than [-0.05, 0.05], an improper y-limit will be set in the function
WaveformPlotting.__plot_set_y_ticks().To solve this, I just add if-statements to set an extremely small y-limit for this specific issure. This issue might be extremely unlikely to occur in real data, but I encountered it during my synthetic seismogram research, so I submitted this PR.
PR Checklist
masterfor new features,maintenance_...for bug fixesready for reviewlabel when you are ready for the PR to be reviewed.