This is generally a very difficult thing to do, as the position and
the extent of the text is determined when the figure is drawn.
The best way, I guess, is to create a customized Text class, but I do
not recommend this unless you're familiar with matplotlib internals.
If you're using svn version, you can use patheffect.
Otherwise, the easiest workaround is calling "draw" twice (or
"savefig" twice). But, getting this right is a bit tricky. For your
example, adding another "p.draw()" right after "p.text" will work.
Also note that your current code has some issues with zorder,
facecolor of the shadow and too small shadow offsets.
On Tue, Jan 19, 2010 at 7:11 AM, Jens_M <jens.melinder@...> wrote:
> I'm trying to make a shadow effect behind text boxes in a plot (similarly to
> what can be done with legends).
> After a fair bit of searching around I found the matplotlib.patches.Shadow
> class which seems to be good for this. But I cannot get it to work properly.
> I suspect it has something to do with different transforms being used for
> the text itself and the actual bbox that surrounds it. This is what I have
> import numpy as n
> import pylab as p
> import matplotlib.patches as pt
> This seems to produce nothing at all (or maybe something that is far outside
> the axis limits).
> Am I missing something obvious here? Is there some other method that will do
> this in an easier way?
> Would appreciate any help, cheers
> View this message in context: http://old.nabble.com/text-box-shadow-tp27224851p27224851.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
> Throughout its 18-year history, RSA Conference consistently attracts the
> world's best and brightest in the field, creating opportunities for Conference
> attendees to learn about information security's most important issues through
> interactions with peers, luminaries and emerging and established companies.
> Matplotlib-users mailing list