Shadowed Text?

Hello,

I am placing a text object in a place where the background is sometimes
dark and sometimes light, so the text is hard to see. Adding a
background to the text object itself looks a bit ugly, so I am wondering
if there is a way to add a shadow to the text itself.

What's the best way to do this?

I thought about redrawing the same text just offset by a fraction of the
text size, but I can't quite figure out how to do the placement
properly. My rough idea is the get the position of the text in pixel
coordinates, add an offset to it and then position it with display
coordinates as well. But how do I get the display coordinates of
something that I placed in axes coordinates? And how to I determine how
many pixels I need to offset without knowing the dpi?

Best,

   -Nikolaus

···

--
»Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C

You may use annotate with which you can specify offsets.

http://matplotlib.sourceforge.net/api/pyplot_api.html?highlight=annotate#matplotlib.pyplot.annotate

Or, you may consider to use the path_effect (available w/ v1.0).

http://matplotlib.sourceforge.net/examples/pylab_examples/patheffect_demo.html

Regards,

-JJ

···

On Wed, Nov 3, 2010 at 10:44 AM, Nikolaus Rath <Nikolaus@...3072...> wrote:

Hello,

I am placing a text object in a place where the background is sometimes
dark and sometimes light, so the text is hard to see. Adding a
background to the text object itself looks a bit ugly, so I am wondering
if there is a way to add a shadow to the text itself.

What's the best way to do this?

I thought about redrawing the same text just offset by a fraction of the
text size, but I can't quite figure out how to do the placement
properly. My rough idea is the get the position of the text in pixel
coordinates, add an offset to it and then position it with display
coordinates as well. But how do I get the display coordinates of
something that I placed in axes coordinates? And how to I determine how
many pixels I need to offset without knowing the dpi?

Best,

-Nikolaus

--
»Time flies like an arrow, fruit flies like a Banana.«

PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C

------------------------------------------------------------------------------
Achieve Improved Network Security with IP and DNS Reputation.
Defend against bad network traffic, including botnets, malware,
phishing sites, and compromised hosts - saving your company time,
money, and embarrassment. Learn More!
http://p.sf.net/sfu/hpdev2dev-nov
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi,

Fantastic, path_effect is exactly what I'm looking for. Thanks!

-Niko

···

On 11/02/2010 10:16 PM, Jae-Joon Lee wrote:

You may use annotate with which you can specify offsets.

http://matplotlib.sourceforge.net/api/pyplot_api.html?highlight=annotate#matplotlib.pyplot.annotate

Or, you may consider to use the path_effect (available w/ v1.0).

http://matplotlib.sourceforge.net/examples/pylab_examples/patheffect_demo.html

Regards,

-JJ

On Wed, Nov 3, 2010 at 10:44 AM, Nikolaus Rath <Nikolaus@...3072...> wrote:

Hello,

I am placing a text object in a place where the background is sometimes
dark and sometimes light, so the text is hard to see. Adding a
background to the text object itself looks a bit ugly, so I am wondering
if there is a way to add a shadow to the text itself.

What's the best way to do this?

I thought about redrawing the same text just offset by a fraction of the
text size, but I can't quite figure out how to do the placement
properly. My rough idea is the get the position of the text in pixel
coordinates, add an offset to it and then position it with display
coordinates as well. But how do I get the display coordinates of
something that I placed in axes coordinates? And how to I determine how
many pixels I need to offset without knowing the dpi?

Best,

  -Nikolaus

--
»Time flies like an arrow, fruit flies like a Banana.«

PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C

------------------------------------------------------------------------------
Achieve Improved Network Security with IP and DNS Reputation.
Defend against bad network traffic, including botnets, malware,
phishing sites, and compromised hosts - saving your company time,
money, and embarrassment. Learn More!
http://p.sf.net/sfu/hpdev2dev-nov
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

   -Nikolaus

--
»Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C