I would like a custom formatter that does 3 things:
1) Blanks out all the values less than 0.
2) Chooses appropriate major ticks when zoomed out.
3) Shows an integer when the zoom scale is revealing multiple
integers, but shows a decimal number when it is just showing within
one integer; i.e. if it is 1, 2, 3, 4 in first case but 1.1, 1.2,
1.3, 1.4 in the second.
So far I have needs (1) and (2) of this with this super-simple custom formatter:
def __call__(self, val, pos=None):
if val < 0:
But how can I get need (3)? I need to know what the view_interval is
to set a rule for this. Something like:
if view_interval < 1:
return val #this will be a decimal number
return int(val) #an integer
So how do I get the view_interval? I'm not understanding how to get
that from matplotlib.ticker.TickHelper()--if that is even the right
way to do it--because get_view_interval() is not a method of
TickHelper but of "DummyAxis", and at that point I've lost the idea.
Any help is appreciated. Thanks,