-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: improve symlog ticker #21096
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
FIX: improve symlog ticker #21096
Conversation
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Fixes matplotlib#20516 PGF's `random steps` decoration seems to be the most similar, but does not exactly match the behaviour described in matplotlib's docs. Therefore I repurposed the `randomness` argument as a seed to give control on how the line looks afterwards.
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Switch documented deprecations in mathtext by `__getattr__` deprecations
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
…_output API: rename draw_no_output to draw_without_rendering
Make warning for no-handles legend more explicit.
Remove unused HostAxes._get_legend_handles.
Redirect to new 3rd party packages page
legend_handler_map cleanups.
Clean up some Event class docs.
- parse() already normalizes prop=None to prop=FontProperties(). - We don't need to explicitly attach a canvas to a plain Figure() before calling savefig() anymore; FigureCanvasBase is always attached and handles the dispatching to the correct concrete canvas class.
According to the docs, this function was added in GTK 2.2, so probably was only needed when we supported GTK2. It also no longer exists in GTK4.
Since these examples don't need to support the very oldest GTK3, I took the opportunity to rewrite them using the recommended Application-styled model.
The `Gtk.Window.destroy` doesn't work, but `.close` correctly triggers our cleanup.
I think the better fix is to change |
Maybe? We often return out of bounds ticks so I wasn't sure if that was desired here. |
What do you mean by out of bounds ticks? I think changing |
Consider import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
loc = mticker.LogLocator()
print(loc.tick_values(1e-3, 1e3)) This returns
and note that the first and last ticks are (well) outside the vmin and vmax. |
Ah I think that's because the |
No, I mean the hi lim uses |
Sorry, I got a bit confused. to go back to my original suggestion, changing matplotlib/lib/matplotlib/ticker.py Line 2519 in a6e01b5
from |
@dstansby We want one tick below vmin and one tick above vmax, and then we clip them when we draw the axis. |
In general yes, but that's not what this PR is about - the vmin/vmax of the Axis are distinct from the linear threshold of the ticker. As you say right at the top:
Changing the matplotlib/lib/matplotlib/ticker.py Line 2519 in a6e01b5
to ceil solves the issue, and is a much simpler and easy to follow piece of code than what is currently proposed. |
That same code is used above and below the threshold... |
I don't think we're doing a very good job of convincing each other 😄 - I won't block this, but leave for others to review. |
Well let me try again: |
For the a and c ranges the calls are: get_log_range(abs(a_upper_lim), abs(vmin) + 1)
get_log_range(c_lower_lim, vmax + 1) The first argument for both the a and c ranges is |
Oh duh, my apologies, you are absolutely correct. I've fixed it. Sorry for being so dense... |
Don't worry! Sorry for not explaining very well! |
Hmm, except that fails MasterSuggested by @dstansbyMy suggestionI guess not of these are quite right (i.e. the first axes should have more than just a zero tick!) |
Ahh I think this is because of the floating point issues using
From memory, in this case the locator should just end up using the default linear locator? |
This PR is affected by a re-writing of our history to remove a large number of accidentally committed files see discourse for details. To recover this PR it will need be rebased onto the new default branch (main). There are several ways to accomplish this, but we recommend (assuming that you call the matplotlib/matplotlib remote git remote update
git checkout main
git merge --ff-only upstream/main
git checkout YOUR_BRANCH
git rebase --onto=main upstream/old_master
# git rebase -i main # if you prefer
git push --force-with-lease # assuming you are tracking your branch If you do not feel comfortable doing this or need any help please reach out to any of the Matplotlib developers. We can either help you with the process or do it for you. Thank you for your contributions to Matplotlib and sorry for the inconvenience. |
PR Summary
SymLogLocator
is supposed to not show any ticks in the range [-linthres, linthresh], except for zero. However, thefloor
call can leave a tick inside the lin threshold region, and this usually looks quite bad.Before
After:
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).