-
Notifications
You must be signed in to change notification settings - Fork 551
Stream dayplot: Fix some issues with x tick positioning and labeling #3361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
showing labels with integer numbers when the location of the label is actually at an odd position with decimal numbers. Only cut of '.0' if actually the tick is at an integer position
e.g. for time going from 0-10 minutes we need 11 ticks, not 10, to place them on integer numbers
don't fix to 5 ticks if less then 5 were determined somehow, just keep multiplying with 2 so we keep the ticks at sane positions
count = 10 wasnt used as a default here due to faulty logic
36f8129
to
6d5e3a5
Compare
Test fail is unrelated, should be good to go |
# To get a thick curve alternate between two curves. | ||
data = np.empty(number_of_samples) | ||
# Check if even number and adjust if necessary. | ||
if number_of_samples % 2 == 0: | ||
data[0::2] = curve | ||
data[1::2] = curve + 0.2 | ||
else: | ||
data[-1] = 0.0 | ||
data[0:-1][0::2] = curve | ||
data[0:-1][1::2] = curve + 0.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is just the original code, but isn't it basically:
# To get a thick curve alternate between two curves. | |
data = np.empty(number_of_samples) | |
# Check if even number and adjust if necessary. | |
if number_of_samples % 2 == 0: | |
data[0::2] = curve | |
data[1::2] = curve + 0.2 | |
else: | |
data[-1] = 0.0 | |
data[0:-1][0::2] = curve | |
data[0:-1][1::2] = curve + 0.2 | |
# To get a thick curve alternate between two curves. | |
curve[1::2] += 0.2 | |
# Check if even number and adjust if necessary. | |
if number_of_samples % 2 == 1: | |
curve[-1] = 0.0 |
(and then data == curve
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like data is twice as long as curve and then curve gets squashed in twice there? in any case, not worth spending time on beautifying this piece of super old test code, I'd say. :)
What does this PR do?
This PR fixes two partially interacting problems with how Stream "dayplots" (helicorder plots) are ticked and labeled on the x-Axis.
1. Tick Positioning
When "number_of_ticks" is not set, in many cases with sensible choice of "interval" parameter, bad automatic choice of number of x ticks were made. E.g. with "interval=10", 10 x ticks were used (should be 11), so that all ticks fall on decimal numbers.
2. Tick Labeling
The labeling of x-ticks was forced to
"%i" % x
, i.e. forcibly cutting of any decimals. In principle it is desirable to show "3" instead of "3.0" for the ticks but combined with the former problem leading to many cases of oddly placed ticks this was leading to plots having wrong labeling in many cases (e.g. labels 0, 1, 2, 3, ..., 12, 13, 15 with ticks not actually placed at these integers numbers).Examples
1. Automatic routine selecting number of ticks giving picking bad number of ticks
Notice how tick labels jump from "8" to "10" on last tick label. Ticks are actually not at the integer number positions that are suggested by the labels, but rather oddly placed due to only 10 ticks for a range 0-10 (should be 11 ticks).
Before:

After: 11 ticks are chosen and now ticks actually are at the integer positions

2. User chooses weird number of ticks and labeling is wrong
User chooses weird parameters, but at first glance the plot looks OK, since it does not show correct labels, all labels are decimal numbers at weird positions.
Before:


After: ticks are still placed oddly due to user explicit choice, but now it is clear that ticks are off
Why was it initiated? Any relevant Issues?
Got contacted in private mail with an example of this problem
PR Checklist
master
for new features,maintenance_...
for bug fixesno_ci
label can be added to skip CI buildsJust add the
build_docs
tag to this PR.Docs will be served at docs.obspy.org/pr/{branch_name} (do not use master branch).
Please post a link to the relevant piece of documentation.
clients.fdsn
) should be tested for the PR,just add the
test_network
tag to this PR.CHANGELOG.txt
.CONTRIBUTORS.txt
.from all the CI builds look correct. Add the "upload_plots" tag so that plotting
outputs are attached as artifacts.
CODEOWNERS
with your github handleready for review
label when you are ready for the PR to be reviewed.