First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!

Ask Your Question
1

How to insert non overlapping text in matplotlib?

asked Nov 19 '12

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.

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 (Nov 19 '12)

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 (Nov 20 '12)

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 (Nov 20 '12)

1 answer

Sort by » oldest newest most voted
0

answered Feb 22 '17

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])

link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.
Want to format code in your answer? Here is a one minute demo on Youtube

Add Answer

[hide preview]

Question Tools

Stats

Asked: Nov 19 '12

Seen: 8,087 times

Last updated: Feb 22 '17