You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect labels returned with custom formatter and locator #9397
FWIW, if it is not the correct behavior, I was able to reproduce @astrofog's output on Matplotlib 1.5.3 (on GNU/Linux with Python 3.6.2 from conda)...
Just in case, looking at FuncFormatter docstring, the expected signature is formatter_func(x, pos): @astrofrog is this consistent with what you intended?
diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py
index 6cc38bb90..39ac54de1 100644
--- a/lib/matplotlib/axis.py
+++ b/lib/matplotlib/axis.py
@@ -1052,11 +1052,11 @@ class Axis(artist.Artist):
for tick, loc, label in tick_tups:
if tick is None:
continue
- if not mtransforms.interval_contains(interval_expanded, loc):
- continue
tick.update_position(loc)
tick.set_label1(label)
tick.set_label2(label)
+ if not mtransforms.interval_contains(interval_expanded, loc):
+ continue
ticks_to_draw.append(tick)
return ticks_to_draw
fixes the issue. Basically, the idea is to update the tick labels (and positions) even if they're not going to be drawn (this should be fairly cheap). Feel free to turn the patch into a PR.
I've argued in a few places that we should just be more careful to actually only have the ticks that are going to be drawn, and not have excess ones on either side.
Activity
afvincent commentedon Oct 13, 2017
FWIW, if it is not the correct behavior, I was able to reproduce @astrofog's output on Matplotlib 1.5.3 (on GNU/Linux with Python 3.6.2 from conda)...
Just in case, looking at
FuncFormatterdocstring, the expected signature isformatter_func(x, pos): @astrofrog is this consistent with what you intended?anntzer commentedon Oct 14, 2017
Looks like
fixes the issue. Basically, the idea is to update the tick labels (and positions) even if they're not going to be drawn (this should be fairly cheap). Feel free to turn the patch into a PR.
I've argued in a few places that we should just be more careful to actually only have the ticks that are going to be drawn, and not have excess ones on either side.