-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Support url on more Artists in svg #17338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Ah, |
My guess is that the backcompatible approach would be to add a |
There is already |
We could do a bit of inspection and only pass the urls if they are supported? We have been doing that in several other places when changing the signature of internal functions that may have been sub-classed. Extending |
lib/matplotlib/collections.py
Outdated
use_urls = 'urls' in sig.parameters | ||
if use_urls: | ||
renderer.draw_quad_mesh( | ||
gc, transform.frozen(), self._meshWidth, self._meshHeight, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor suggestion to make the code more concise:
kw = dict(urls=self.get_urls()) if use_urls else {}
renderer.draw_quad_mesh(gc, transform_frozen(), self._meshWidth, self._meshHeight,
coordinates, offsets, transOffset, self.get_facecolor(),
self._antialiased, self.get_edgecolors(), **kw)
I'm not sure that trying to add urls to quadmesh this way is going to be useful. You would need to go through all the same dimension checks when setting the urls that you have to go through for the colors, to make sure that the urls match the quadrilaterals that are actually shown. It gets complicated. And is quadmesh the right tool for this? Quadmesh shines when working with big arrays, but urls are only going to make sense for very small arrays--say a dozen blocks of color. For that, pcolor works fine. So adding url support to pcolor might make sense (if it doesn't already exist), but for pcolormesh it's not worth the pain. |
Introspection won't work for things that can reasonably be implemented in C, e.g. mplcairo's draw_quad_mesh. (I'm fine for doing introspection on things that are rather unlikely to be implemented in C, e.g. FuncFormatter functions.) |
Well, someone did ask for it, so I'm not sure it's totally inconceivable. Also, the URL does not have to be an actual URL that points to an external website. It could be a query or fragment for the current page or something used by some JS later. I understand we aren't too good about the dimensions, so I guess I'd wait for #16908 for what we really want to accept. |
On a bit more thought, do want want to merge the non-quadmesh changes and defer the API extension / inspection until 3.4? |
lib/matplotlib/collections.py
Outdated
coordinates, offsets, transOffset, self.get_facecolor(), | ||
self._antialiased, self.get_edgecolors()) | ||
try: | ||
sig = inspect.signature(renderer.draw_quad_mesh) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted above I really don't think this is the correct (extensible) approach. Hence blocking, but just as a marker of "this specific point needs more discussion".
Let's do the non-QuadMesh stuff now, and defer that one for later. |
In the class Tick, the url attribute is not passed to any of the objects that are to be drawn. Suggested solution is to override the set_url() method in Tick to transfer the url attribute content to the tick labels, that are to be drawn.
PR Summary
Add
Line2D
,andQuadMesh
,Ticks
(from #9696.)Fixes #9695.
Fixes #17336.
Don't know if this should be documented.
PR Checklist