Ask Your Question
1

How to insert non overlapping text in matplotlib?

asked 2012-11-18 19:34:35 -0600

amaity gravatar image

I am trying to insert power flow results in a network plot created with matplotlib. Some buses are so close that labelling the names along with power flow results is proving to be a big headache because text overlap is making some portions unreadable.

Is there some way to use the bounding box of the text to determine whether the text overlaps the plot lines and/or some other text?

This is a repost of a request posted in stack overflow.

edit retag flag offensive close merge delete

Comments

How are you creating the network plot locations? I experimented with networkx on the weekend and found that you must run a layout algorithm with multiple passes in order to prevent overlapping buses and text. https://github.com/jtrain/psse_sld_viewer

JervisW gravatar imageJervisW ( 2012-11-19 15:19:49 -0600 )edit

I am using an initial mapping (as indicated in the 'move buses in slider diagram' post as a start off point. I now trying to put together an algorithm to place the power flow results without overlapping either on the plot lines or previously inserted text.

amaity gravatar imageamaity ( 2012-11-20 09:09:43 -0600 )edit

I can't figure out a way to obtain the bounding box of the plotted items. My understanding of the underlying matplotlib classes/functions does not seem to be up to the task. By the way, the add comment feature does not seem to be working in IE9.

amaity gravatar imageamaity ( 2012-11-20 09:13:54 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-02-22 17:12:19 -0600

EBahr gravatar image

I know this it late to the game, but I would try tight_layout. The following works well for me : plt.tight_layout(rect=[0, 0.03, 1, 0.95])

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

Stats

Asked: 2012-11-18 19:34:35 -0600

Seen: 7,930 times

Last updated: Feb 22 '17