pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/vispy/vispy/pull/2196

" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/github-eab9c5888b163e42.css" /> Axis visual tick density by MariusAdrian88 · Pull Request #2196 · vispy/vispy · GitHub
Skip to content

Axis visual tick density#2196

Open
MariusAdrian88 wants to merge 5 commits into
vispy:mainfrom
MariusAdrian88:AxisVisual_tick_density
Open

Axis visual tick density#2196
MariusAdrian88 wants to merge 5 commits into
vispy:mainfrom
MariusAdrian88:AxisVisual_tick_density

Conversation

@MariusAdrian88

Copy link
Copy Markdown
Contributor

Add a way to control the AxisVisual tick density

@djhoese

djhoese commented Aug 25, 2021

Copy link
Copy Markdown
Member

This likely has a pretty big overlap with #2016. That PR was going to try to match matplotlib's interface. FYI to @lukasz-migas

Comment thread vispy/visuals/axis.py
Comment on lines +216 to +218
@property
def tick_density(self):
return self._tick_density

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread vispy/visuals/axis.py
Comment on lines -395 to +412
major = _get_ticks_talbot(domain[0], domain[1], n_inches, 2)
major = _get_ticks_talbot(domain[0], domain[1], n_inches, self._tick_density)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since tick_density is 1 by default, should we multiply with 2 here to get the same results as before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since tick_density is 1 by default, should we multiply with 2 here to get the same results as before?

Oops.

Comment thread vispy/visuals/axis.py Outdated
----------
axis : instance of AxisVisual
The AxisVisual to generate ticks for.
tick_density: int, higher number more ticks/labels

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a float? If I want less ticks, can I do tick_density=0.5?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update this once I get home.

Comment thread vispy/visuals/axis.py Outdated
Comment on lines +63 to +64
tick_density: int
Higher number than 1 means more ticks/labels

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect this to be a float.

@djhoese

djhoese commented Aug 26, 2021

Copy link
Copy Markdown
Member

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 brisvag left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread vispy/visuals/axis.py
Comment on lines +221 to +225
@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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy