tomicapretto / flexitext

Flexitext: Draw styled text in Matplotlib
https://tomicapretto.github.io/flexitext/
MIT License
114 stars 8 forks source link

plt.subplots? #6

Closed JiWenzheng closed 3 years ago

JiWenzheng commented 3 years ago

Hi, I want to use Flexitext to draw the text of subplots, but I find that parameter transform = axes. TransAxes is not supported. Is it possible to specify coordinate system in the future?

tomicapretto commented 3 years ago

Do you mean something like this?

import matplotlib.pyplot as plt
from flexitext import flexitext

fig, ax = plt.subplots(1, 2, figsize=(12, 6))

text1 = "<size:42, name:Calibri>Some<color:#11557c, weight:bold> text</></>"
text2 = "<size:36, name:Lato, color:royalblue><weight:bold>Here</> too</>"

flexitext(0.5, 0.5, text1, ha="center", ax=ax[0])
flexitext(0.5, 0.5, text2, ha="center", ax=ax[1])

fig.set_facecolor("w")
fig.savefig("example.png", dpi=300)

example

JiWenzheng commented 3 years ago

Thank you, I understand how to deal with it, it seems that my understanding of matplotlib needs to be improved.