. Hello, everyone.
I recently try to add text object in my plot. But when I zoom into the text, the text size remains unchanged. What I want to have is that the text size will increase when I zoom in and will decrease when I zoom out.
import matplotlib as mpl
fig=plt.figure()
ax1=fig.add_subplot(111)
ax1.text('','', '',position=[0.5,0.5], text='Y', fontsize='xx-small' )
Any help is appreciated. Thanks~
Supplement-UTC+8 30/04/2013 9:40 AM
Thanks for the suggestion from tcaswell. TextPath does achieve part of my purposes.
I found there is no documentation about textpath in official matplotlib website, so I view the source code to see what it does. Finally, I achieved a not excellent but satisfactory result as follows.
from matplotlib.textpath import TextPath
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib.path import Pathfig=plt.figure()
ax1=fig.add_subplot(111)
tp1=TextPath((0.5,0.5), r'How do you turn this on?', size=1)
polygon=tp1.to_polygons()
for a in polygon:p1=patches.Polygon(a)ax1.add_patch(p1)
The not excellent part of this code is that it doesn't support rotation and export the text as filled polygon. Is there any easy way to rotate the text? Can I export the text as non-filled polygon?