0

I want to add text to an axis that will display a title, but need some standardization as it will be used in a process to dynamically create axes. The text has a black background, so I want the width to be set to a number where the longest title will fit. Is there something similar to bbox that can be used?

Setup in a nutshell: there's an outergrid of 5 objects, with each having several subplots that make up an inner grid. I don't know if subplots have limited customization, but that's currently what I'm working with.

ax = plt.Subplot(fig, inner_grid[:3, :8])
ax.text(x, y, txt, rotation=0, color='white', size=10, fontweight='bold', backgroundcolor='black' ) 

How do I set a width?

jma
  • 457
  • 7
  • 18
  • Related questions: [Q1](https://stackoverflow.com/questions/40796117/how-do-i-make-the-width-of-the-title-box-span-the-entire-plot), [Q2](https://stackoverflow.com/questions/35249489/side-specific-padding-for-matplotlib-text-bbox?noredirect=1&lq=1), [Q3](https://stackoverflow.com/questions/47611399/matplotlib-how-to-specify-width-of-x-label-bounding-box). I' m not sure which mechanism you want to use here to determine the size of the black box. Probably a complete example would help. – ImportanceOfBeingErnest Dec 04 '17 at 15:40
  • @ImportanceOfBeingErnest -- perfect! Thank you so much. – jma Dec 04 '17 at 17:24
  • Does that mean that the quesiton is solved? if so, which one of the links helped you? We can then mark as duplicate. Otherwise, if this is not yet solved, what are the remaining problems? – ImportanceOfBeingErnest Dec 04 '17 at 18:23

0 Answers0