-
Notifications
You must be signed in to change notification settings - Fork 89
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 markers strike through text #79
Comments
Hi, thank you for reporting. |
So I am using ROS (Robot operating System) to launch this node. If you have used it as well, the following node can be launched from a launch file and will display most of the above picture. The code is a bit round about in places, the string and points which are hard coded are actually pulled from a yaml file which loads those variables to the ros parameter server:
Working on a pure python code. |
The following code with the ROS stuff removed:
Cam you maximize the window? the arrow strike throughs are only visible when you maximize the window on linux. |
Thanks for creating this code btw, helped me out loads. This is a great functionality! |
Right... Well adjust_text is not really designed for interactive windows, I'm not sure what happens when the figure gets resized. I don't know why this behaviour is observed, and to be honest don't even know where to start. But I guess this has something to do with the fact that text has constant physical size, and the arrow - constant size in data coordinates. And if stretched to much from the original size, something breaks. Generally, the arrow should start from the center of the test object, but should be clipped by its bounding box. |
Somehow changing the adjust_text function to end annotation at the following point works:
where newpointpori=
|
Copying adjust_text code from line 646:
|
If it works for you (the arrows should scale with minimizing-maximizing window) I can submit a PR. I mentioned it to be hacky as I did not go through the rest of the code. |
Well, I imagine this solution will produce arrows that don't reach the text, if the text is far away from the point?.. |
Yep possibly, though I haven't tested it. Do you know of any other libraries with dynamic spacing of texts? I can maybe look into solving this. |
What do you mean by dynamic spacing of texts? |
Changes the position of texts based on other texts around it, kind of what adjust text does. |
I don't know any other library that does it with matplotlib, sorry |
This can probably be solved with some transformations... |
From what I remember, it seemed like matplotlib bug or something like that. I had a feeling it was fixed or improved with some matplotlib update... But that's all I can say at the moment, unfortunately. |
I had matplotlib 3.6.2. I just updated to 3.7.0, but it didn't change anything :( |
I guess I just have to make my labels shorter. |
Found the mpl bug about this! |
The end point of the arrows is somehow defined on the corner edge of the text. I am using the text wrap library to break up long lines of text so that could be the problem (though removing that did'nt help either). The problem can be seen when the window is maximized. Please see attached picture for reference.
I edited the source code simply by dividing the line in half. I expected it to go to the midpoint of the text now but somehow the end of the arrow rests on the right location (tip of the text box). I didn't have time to look through the code as to the unexpected behavior. I'll be glad to submit the pull request (not sure how hacky it is).

The following picture is with fixed code:

Both windows are maximized.
The text was updated successfully, but these errors were encountered: