| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
This seems OK to me. But isn't the root problem that there are two zeros returned by the Locator? Can't we just remove the duplicate entry from the Locator?
Sorry, something went wrong.
|
matplotlib/lib/matplotlib/ticker.py Line 2215 in 64874e5 matplotlib/lib/matplotlib/ticker.py Line 2353 in 64874e5 |
Sorry, something went wrong.
There was a problem hiding this comment.
The strategy of this PR can't work. If you run e.g. examples/pyplots/pyplot_scales.py with this PR applied, and move or zoom the symlog axes, the label at 0 disappears (because it is never redrawn).
I believe that @jklymak's idea is the correct approach.
Sorry, something went wrong.
|
That’s a great point. I’ll spend some more time in the locator and the linear approximation around zero and see if there’s a good way to ensure only a single zero value.
…On Dec 29, 2017, 2:14 PM -0600, Antony Lee ***@***.***>, wrote:
@anntzer requested changes on this pull request.
The strategy of this PR can't work. If you run e.g. examples/pyplots/pyplot_scales.py with this PR applied, and move or zoom the symlog axes, the label at 0 disappears (because it is never redrawn).
I believe that @jklymak's idea is the correct approach.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Sorry, something went wrong.
|
@jklymak @anntzer Thanks for your help and patience, I believe this is the root of the issue. The multiple zeros are stemming from subticks being added. This change just prevents the addition of subticks to the zero label (since they will all be zero). |
Sorry, something went wrong.
|
👍 That makes sense and looks like a reasonable fix. Could you add a test? I suspect creating a symlog axis and then asserting that there is only 0 zero label it in is the best approach (no need for an image test). The OP example is maybe a bit complex to trigger this, but as a last resort would be ok to use a test. |
Sorry, something went wrong.
There was a problem hiding this comment.
Fix looks good, just needs a test.
Anyone can dismiss this when a test is added.
Sorry, something went wrong.
Dismissing @tacaswell review as test now added per his wishes
|
Just for completeness, the test is: from matplotlib import pyplot as plt
import matplotlib as mpl
fig, axes = plt.subplots(1, 2, True, True)
for i, ax in enumerate(axes):
im = ax.imshow([[0]], norm=mpl.colors.SymLogNorm(1e-5, vmin=-1, vmax=1))
cb = plt.colorbar(im, ax=ax)
# Clean up the labels
zero_labelled = False
for label in cb.ax.yaxis.get_ticklabels():
if label.get_text() == r'$\mathdefault{0}$':
if zero_labelled:
label.set_visible(False)
zero_labelled = True
plt.show() |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Use the previously unused position of a tick label to ensure that only a single zero label is rendered when using SymLogNorm. I store the first time a zero label is encountered and return blanks for all following zeros. The documentation on the ticker.SymmetricalLogLocator.tick_values shows how these multiple zeros come to be through the linear approximation near zero.
As per discussion below I have taken a different approach, trying to fix the root cause of the problem in the locator (ticker.SymmetricalLogLocator.tick_values) so that the extra zero ticks are never created in the first place.
Fixes #10122
PR Checklist