Here is the example that I believe that does what you want. The way it does is very similar to how legend object is created. Unfortunately, the offsetbox module, which enables this example, is not well documented. I hope the example is explanatory enough.
IHTH, -JJ import matplotlib.pyplot as plt from matplotlib.offsetbox import TextArea, DrawingArea, HPacker, AnnotationBbox import matplotlib.lines as mlines ax = plt.subplot(111) fontsize=15 box1 = TextArea("This is the square marker :", textprops=dict(color="k", size=fontsize)) # create a drwaing area for a marker # It will have width*height = fontsize*0.8fontsize # and xdescent, ydescent = 0*0.2fontsize box2 = DrawingArea(fontsize, 0.8*fontsize, 0, 0.2*fontsize) # maker l1 = mlines.Line2D([0.5*fontsize], [0.25*fontsize], marker="s", markersize=(0.5*fontsize)) # add the marker to the drawing area box2.add_artist(l1) # now combine the textarea and the drawing area (marker) box = HPacker(children=[box1, box2], align="baseline", pad=0, sep=fontsize*0.2) # Use AnnotationBbox object using *box*. Note that the AnnotationBbox is very similar to annotate. It uses offsetbox object instead of the text object a_box = AnnotationBbox(box, xy=(0., 1.), xycoords='data', xybox=(fontsize, -fontsize), boxcoords="offset points", box_alignment=(0., 1), frameon=True, ) ax.add_artist(a_box) plt.show() On Wed, Nov 24, 2010 at 1:22 AM, Alejandro Weinstein <alejandro.weinst...@gmail.com> wrote: > Hi: > > I want to use the symbol corresponding to a marker in a text > annotation. Something like > > textstr = 'This is the square marker: ?' > ax.text(0.05, 0.95, textstr) > > Is there something I can place where the question mark is above to get > the actual square (or any other of the symbols you can use as a > marker)? > > This is similar to what the legend command does, but I need more flexibility. > > Alejandro. > > ------------------------------------------------------------------------------ > Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! > Tap into the largest installed PC base & get more eyes on your game by > optimizing for Intel(R) Graphics Technology. Get started today with the > Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. > http://p.sf.net/sfu/intelisp-dev2dev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users