Skip to content
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

Arrow color to text color? #6

Open
alphapapa opened this issue Oct 20, 2016 · 4 comments
Open

Arrow color to text color? #6

alphapapa opened this issue Oct 20, 2016 · 4 comments

Comments

@alphapapa
Copy link

Hi,

I found this package from http://stackoverflow.com/a/34762716/712624 and I have to say, it's amazing! I was trying to do this myself, manually, and when I realized how not-simple it was, I luckily stumbled upon this project. It does a great job!

The only downside seems to be that I can't set the arrowprops for each line. For example, I want the arrow color to match the text color, but since I pass adjust_text a list of text objects, I can't pass data for each object individually.

I realize that solving this would seem a bit hacky, but is it something you'd be willing to implement or accept a patch for?

Thanks for this great project!

@Phlya
Copy link
Owner

Phlya commented Oct 21, 2016

Hi,
Thank you, I am glad you like it.

Yes, currently it is not possible... I would be happy to accept a PR for this, I myself don't have time right now to try and implement this. In my opinion, the best solution would be fixing the other issue you reported, then all properties of annotations can be set during their creation as required, and here we then only move them.

@bertsky
Copy link

bertsky commented Feb 24, 2021

Note: you can set the color of the arrows according to their respective labels ex post by:

  • keeping track of the artists added to ax.texts after adjust_text, and then
  • zipping each new artist with the old ones and copying the color:
nlabels = len(ax.texts)
adjust_text(ax.texts, ...)
for new, old in zip(ax.texts[nlabels:], ax.texts):
    new.arrow_patch.set_color(old.get_color())

(If your blueprint is a different kind of object, like ax.patches, you might need to use get_edgecolor() or the like.)

Example:

@edlemus
Copy link

edlemus commented Nov 3, 2022

@bertsky AdjustText doesn't have arrowpatch attribute, how were you able to accomplish changing the color of the arrow? I have the same problem but with a graph

@bertsky
Copy link

bertsky commented Nov 3, 2022

@edlemus what do you mean adjust_text does not have an attribute? It's just a function on matplotlib.text.Text instances.
See https://github.com/i008/COCO-dataset-explorer/blob/df82a833163d7acc131eefb5264684cb2cc627b5/vis.py#L116-L119 for example.

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

No branches or pull requests

4 participants