Axis visual tick density#2196
Conversation
|
This likely has a pretty big overlap with #2016. That PR was going to try to match matplotlib's interface. FYI to @lukasz-migas |
| @property | ||
| def tick_density(self): | ||
| return self._tick_density |
There was a problem hiding this comment.
Needs a docstring. I was wondering if there is a more semantic measure we could adopt, like distance between ticks in logical pixels. But I guess these are different for vertical/horizontal axis, so a relative value makes sense, I guess.
| major = _get_ticks_talbot(domain[0], domain[1], n_inches, 2) | ||
| major = _get_ticks_talbot(domain[0], domain[1], n_inches, self._tick_density) |
There was a problem hiding this comment.
Since tick_density is 1 by default, should we multiply with 2 here to get the same results as before?
There was a problem hiding this comment.
Since tick_density is 1 by default, should we multiply with 2 here to get the same results as before?
Oops.
| ---------- | ||
| axis : instance of AxisVisual | ||
| The AxisVisual to generate ticks for. | ||
| tick_density: int, higher number more ticks/labels |
There was a problem hiding this comment.
Why not a float? If I want less ticks, can I do tick_density=0.5?
There was a problem hiding this comment.
I'll update this once I get home.
| tick_density: int | ||
| Higher number than 1 means more ticks/labels |
There was a problem hiding this comment.
I would expect this to be a float.
|
I could be wrong, but it looks like both this and #2016 don't use the MaxNLocator. Isn't the whole point of that class to do this type of density calculation? If we can match matplotlib interfaces a little bit that would probably be nice. |
brisvag
left a comment
There was a problem hiding this comment.
Very late arrival here, but I think we should merge this.
I agree it would be nice to use the "MaxNLocator", but that's never been in use and hooking it up to the AxisVisual is quite a bit more work than simply exposing the density parameter, which is already very useful.
I also tested a bit the MaxNLocator, and it has a few issues (for example trimming ticks that are outside the domain doesn't really work), which would require more work to fix.
All in all, I think this PR is only missing the line I suggest below.
| @tick_density.setter | ||
| def tick_density(self, val: float): | ||
| self._tick_density = val | ||
| self.ticker = Ticker(self, anchors=self._anchors, tick_density=self._tick_density) | ||
|
|
There was a problem hiding this comment.
| @tick_density.setter | |
| def tick_density(self, val: float): | |
| self._tick_density = val | |
| self.ticker = Ticker(self, anchors=self._anchors, tick_density=self._tick_density) | |
| @tick_density.setter | |
| def tick_density(self, val: float): | |
| self._tick_density = val | |
| self.ticker = Ticker(self, anchors=self._anchors, tick_density=self._tick_density) | |
| self._need_update = True |
Add a way to control the AxisVisual tick density