matplotlib icon indicating copy to clipboard operation
matplotlib copied to clipboard

Add bbox support to quiverkey

Open useidemaisachola opened this issue 6 months ago • 14 comments

-This change was necessary to resolve the issue #29704. -It is now possible to add a bbox (bounding box) around the entire quiverkey label — including both the arrow and the text — using the bbox keyword argument. Previously, bounding boxes could only be added manually or were limited to wrapping just the text, not the full key. This enhancement allows users to apply background color, border, and padding around the complete key for better visibility and styling.

PR checklist

useidemaisachola avatar Jun 06 '25 14:06 useidemaisachola

I will resolve the problems with newlines and blankspaces but, the problems with Tests/ Python 3.12, it's not because of something I did right?

useidemaisachola avatar Jun 06 '25 14:06 useidemaisachola

Oh ok thank you, I will work on that!

useidemaisachola avatar Jun 06 '25 14:06 useidemaisachola

I'm not really sure it's actually a good idea to add bbox support in each artist class one at a time. Instead, it may be more viable to have something like FancyBboxPatch.around_artists(list-of-artists, **kwargs); or at least have bbox support in the base artist class, relying on the generic get_window_extent method to figure out how big to draw the bbox?

anntzer avatar Jun 07 '25 22:06 anntzer

Hm ok, i understand your point, but I did what I understood throught my conversation with the developers on the tab of the issue (I did show the API, etc). Maybe I understood wrong. @story645, @rcomer, what do you think it's the best? Do I have to change my aproach?

useidemaisachola avatar Jun 08 '25 01:06 useidemaisachola

I'm not really sure it's actually a good idea to add bbox support in each artist class one at a time.

Which artists would it make sense to have a bbox for?

Do I have to change my aproach?

Depends - if a method is added to fancy box then yes, if the implementation is in base artist than you'll move the solution into the artist class but you still need to propose the arguments and show examples.

attn @timhoffm

story645 avatar Jun 08 '25 06:06 story645

Hm ok, i understand your point, but I did what I understood throught my conversation with the developers on the tab of the issue (I did show the API, etc).

Please understand that not all developers read all discussions at the same time nor do we all necessarily agree immediately on the best way to implement a feature (or whether we even want it to be added). It is not so rare to have multiple rounds of back and forth between the API-design side and the actual implementation work.

Which artists would it make sense to have a bbox for?

A more general reason why I raised this point is that the current implementation seems to be very tied down to QuiverKey implementation details, but a more generic one (based on get_window_extent) may be possible.

anntzer avatar Jun 08 '25 10:06 anntzer

I have not followed all the details here, but currently QuiverKey does not have a get_window_extent method. I think that in order to implement one, you would need most of the logic currently in _draw_bbox. So, regardless of what the final implementation is, it might be a good idea to factor that out. This would have the added bonus of closing #18530.

rcomer avatar Jun 08 '25 12:06 rcomer

Please understand that not all developers read all discussions at the same time nor do we all necessarily agree immediately on the best way to implement a feature (or whether we even want it to be added). It is not so rare to have multiple rounds of back and forth between the API-design side and the actual implementation work.

Yes, that makes sense, I'm still new at this.

So @story645, @rcomer, in summary, what do you want me to do? I understood your points and views, but I'm unsure what the final decision is.

useidemaisachola avatar Jun 08 '25 19:06 useidemaisachola

I don't think anyone wants you to do anything. Again, the tricky part is figuring out what to do, not so much how to do it.

anntzer avatar Jun 08 '25 22:06 anntzer

@story645, @rcomer, in summary, what do you want me to do?

Like @anntzer said, we've gotta come to consensus for quiverbox. I think for now, you can work on @rcomer 's suggestion of creating a get_window_extent method. That will close an outstanding issue, and if consensus ends up being to generalize the solution than having written the specific solution will help you write the general form.

story645 avatar Jun 09 '25 00:06 story645

Yes, I know, I was talking about the part of being more generic. Ok, thank you, @story645 .

useidemaisachola avatar Jun 09 '25 08:06 useidemaisachola

I'm not really sure it's actually a good idea to add bbox support in each artist class one at a time. Instead, it may be more viable to have something like FancyBboxPatch.around_artists(list-of-artists, **kwargs); or at least have bbox support in the base artist class, relying on the generic get_window_extent method to figure out how big to draw the bbox?

@anntzer I agree that a systematic approach to boxes around Artists would make sense. I have no clear picture yet which approach is the best. Some ideas - feedback welcome:

  • Artist should not have a "builtin" box capability, in the sense that these are exposed via artist properties (something like box_color, box_linewidth). This puts too much onto the base class.
  • Artists could own a box as a child artist. The box would then follow the artist dimensions. This could be convenient, but we should consider:
    • would the box be included in the Artist extent? There are reason to do so and reasons to not
    • This does not allow for boxes around multiple artists
  • Alternatively, boxes could contain Artists in the sense of FancyBboxPatch.around_artists(list-of-artists, **kwargs). Possible obstacles here are that either the boxes are drawn around after-the-fact, which would likely exclude them from layouts, or the Boxes are proper containers, which implies the artist tree is different in one case you have the direct artists (e.g. a Text instance for the title), but if you draw a box around this, there's a FancyBoxPatch that takes the logical position of the title and itself contains the Text.

timhoffm avatar Jun 13 '25 13:06 timhoffm

the boxes are drawn around after-the-fact, which would likely exclude them from layouts

Would this also restrict the box to only being a frame with no facecolor?

rcomer avatar Jun 14 '25 02:06 rcomer

Would this also restrict the box to only being a frame with no facecolor?

No. We can set the zorder appropriately so that the box is drawn before the artist.

timhoffm avatar Jun 14 '25 05:06 timhoffm