plot with drop shadow

Is there a way to plot lines with drop shadows?

Thanks,
Nate

Nothing built-in -- but you can fake it::

    import matplotlib.pyplot as plt
    import numpy as np

    t = np.arange(0.0, 2.0, 0.01)
    s = np.sin(2*np.pi*t)

    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(t+0.01, s-0.01, color='gray', lw=2)
    ax.plot(t, s, color='blue', lw=3)
    plt.show()

JDH

···

On Mon, Dec 1, 2008 at 9:17 AM, Nate <tenpoundwalleye@...9...> wrote:

Is there a way to plot lines with drop shadows?

John Hunter-4 wrote:

Is there a way to plot lines with drop shadows?

Nothing built-in -- but you can fake it::

    import matplotlib.pyplot as plt
    import numpy as np

    t = np.arange(0.0, 2.0, 0.01)
    s = np.sin(2*np.pi*t)

    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(t+0.01, s-0.01, color='gray', lw=2)
    ax.plot(t, s, color='blue', lw=3)
    plt.show()

JDH

So there is no way to say plot a line. Grab that image. Apply a standard
SVG filter (like Gaussian). And overlay the blur? I do not know the PIL
well enough to know if this is feasible.

···

On Mon, Dec 1, 2008 at 9:17 AM, Nate <tenpoundwalleye@...9...> wrote:

--
View this message in context: http://www.nabble.com/plot-with-drop-shadow-tp20773979p20780129.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Along similar lines, has anyone figured
out a way to have a drop shadow effect for text on a plot?

twentypoundtrout <twentypoundtrout@…9…>
12/01/08 01:43 PM

To

matplotlib-users@lists.sourceforge.net
cc

Subject

Re: [Matplotlib-users] plot with drop
shadow

`

John Hunter-4 wrote:

Is there a way to plot lines with drop shadows?

Nothing built-in – but you can fake it::

import matplotlib.pyplot as plt
import numpy as np
t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(t+0.01, s-0.01, color='gray', lw=2)
ax.plot(t, s, color='blue', lw=3)
plt.show()

JDH

So there is no way to say plot a line. Grab that image. Apply
a standard

SVG filter (like Gaussian). And overlay the blur? I do not know the
PIL

well enough to know if this is feasible.

···

On Mon, Dec 1, 2008 at 9:17 AM, Nate <tenpoundwalleye@…9…> wrote:

View this message in context: [http://www.nabble.com/plot-with-drop-shadow-tp20773979p20780129.html

Sent from the matplotlib - users mailing list archive at Nabble.com.


This SF.Net email is sponsored by the Moblin Your Move Developer’s challenge

Build the coolest Linux based applications with Moblin SDK & win great
prizes

Grand prize is a trip for two to an Open Source event anywhere in the world

](http://www.nabble.com/plot-with-drop-shadow-tp20773979p20780129.html)[http://moblin-contest.org/redirect.php?banner_id=100&url=/


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

](http://moblin-contest.org/redirect.php?banner_id=100&url=/)[matplotlib-users List Signup and Options

`](matplotlib-users List Signup and Options)

Mike Hearne wrote:
> Along similar lines, has anyone figured out a way to have a drop shadow effect for text on a plot?

Out of curiosity, what is the payoff
(in communication or aesthetics)
of such a thing?

Thanks,
Alan Isaac

You can do this using an external program -- see for example
A Little Bit of Python, A Little Bit of Astronomy: Applying Filter Effects on SVG files created using Matplotlib. It
would be challenging to implement something like this internally
across output formats I think, but we recently added some features to
make it easier to use an svg editor for filtering mpl objects. See
also this thread

http://www.nabble.com/SVG-clickable-images-td20236869.html#a20236869

JDH

···

On Mon, Dec 1, 2008 at 2:43 PM, twentypoundtrout <twentypoundtrout@...9...> wrote:

So there is no way to say plot a line. Grab that image. Apply a standard
SVG filter (like Gaussian). And overlay the blur? I do not know the PIL
well enough to know if this is feasible.

Alan G Isaac wrote:

Mike Hearne wrote:
> Along similar lines, has anyone figured out a way to have a drop shadow
effect for text on a plot?

Out of curiosity, what is the payoff
(in communication or aesthetics)
of such a thing?

I don't think that it communicates any more information, but it can often
add depth to an otherwise benign figure and can also make the presentation
softer to view. Just makes it fancy I guess.

···

--
View this message in context: http://www.nabble.com/plot-with-drop-shadow-tp20773979p20781124.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

The long answer is: I have a map
with a varying background. I’d like to be able to create a white
drop-shadow behind darker text, so that the text can stand out reasonably
clearly against most colored backgrounds.

The short answer is that my customers
want it.

–Mike

Alan G Isaac <aisaac@…310…>
12/01/08 02:25 PM

To

matplotlib-users@lists.sourceforge.net
cc

Subject

Re: [Matplotlib-users] plot with drop
shadow

`Mike Hearne wrote:

Along similar lines, has anyone figured out a way to have a drop
shadow effect for text on a plot?

Out of curiosity, what is the payoff

(in communication or aesthetics)

of such a thing?

Thanks,

Alan Isaac

···

This SF.Net email is sponsored by the Moblin Your Move Developer’s challenge

Build the coolest Linux based applications with Moblin SDK & win great
prizes

Grand prize is a trip for two to an Open Source event anywhere in the world

[http://moblin-contest.org/redirect.php?banner_id=100&url=/


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

](http://moblin-contest.org/redirect.php?banner_id=100&url=/)[matplotlib-users List Signup and Options

`](matplotlib-users List Signup and Options)

The long answer is: I have a map with a varying background. I'd like to be able to create a white drop-shadow

behind darker text, so that the text can stand out reasonably clearly against most colored backgrounds.

OK. I can imagine this. If I wanted a quick pass at
a cheap substitute for that kind of effect in PostScript, I'd
probably stroke the text outline in white and then fill
in the dark color. Do not know if that is possible in mpl or
desirable for you.

> The short answer is that my customers want it.

Reason enough.

Thanks,
Alan

···

On 12/1/2008 7:27 PM Mike Hearne apparently wrote:

How can I get the actual x,y data that
represents the contour lines that are drawn with the contour() function?

I’d like to be able to redraw portions
of those lines with different styles (dashed, dotted, etc.)

For example, given the following sample
code (lifted from the sourceforge example):

from pylab import *

from numpy import *

delta = 0.025

x = arange(-3.0, 3.0, delta)

y = arange(-2.0, 2.0, delta)

X, Y = meshgrid(x, y)

Z1 = bivariate_normal(X, Y, 1.0, 1.0,
0.0, 0.0)

Z2 = bivariate_normal(X, Y, 1.5, 0.5,
1, 1)

difference of Gaussians

Z = 10.0 * (Z2 - Z1)

figure()

cs = plt.contour(X, Y, Z)

show()

How could I, for example, re-draw the
lines in the region X [0 1] Y [-1.5 -0.5] as dashed?

I could do it, I think, if I had the
for all the lines in the plot.

–Mike

Mike Hearne wrote:

How can I get the actual x,y data that represents the contour lines that are drawn with the contour() function?

I'd like to be able to redraw portions of those lines with different styles (dashed, dotted, etc.)

For example, given the following sample code (lifted from the sourceforge example):

from pylab import *
from numpy import *

delta = 0.025
x = arange(-3.0, 3.0, delta)
y = arange(-2.0, 2.0, delta)
X, Y = meshgrid(x, y)
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
# difference of Gaussians
Z = 10.0 * (Z2 - Z1)
figure()
cs = plt.contour(X, Y, Z)
show()

How could I, for example, re-draw the lines in the region X [0 1] Y [-1.5 -0.5] as dashed?

I could do it, I think, if I had the for all the lines in the plot.

I don't think this is going to make it easy to do what you want, but cs.collections is a list of LineCollection objects corresponding to the contour levels in cs.levels.

Eric

>>I don't think this is going to make it easy to do what you want

It might if I could find the x,y data
in the LineCollection objects. There is an undocumented function
in the LineCollection class called get_paths(), which looks like it returns
a list of Path objects. These path objects have a vertices property
which looks like the stuff I want. I’ll explore this for a while.
Anyone who knows more about these objects, feel free to chime in!

Thanks,

Mike

Eric Firing <efiring@…202…>
12/03/08 01:59 PM

To

Mike Hearne <mhearne@…924…>
cc

matplotlib-users@lists.sourceforge.net
Subject

Re: [Matplotlib-users] Contour line
data

`Mike Hearne wrote:

How can I get the actual x,y data that represents the contour lines
that

are drawn with the contour() function?

I’d like to be able to redraw portions of those lines with different

styles (dashed, dotted, etc.)

For example, given the following sample code (lifted from the

sourceforge example):

from pylab import *

from numpy import *

delta = 0.025

x = arange(-3.0, 3.0, delta)

y = arange(-2.0, 2.0, delta)

X, Y = meshgrid(x, y)

Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)

Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)

difference of Gaussians

Z = 10.0 * (Z2 - Z1)

figure()

cs = plt.contour(X, Y, Z)

show()

How could I, for example, re-draw the lines in the region X [0 1]
Y

[-1.5 -0.5] as dashed?

I could do it, I think, if I had the for all the lines in the plot.

I don’t think this is going to make it easy to do what you want, but

cs.collections is a list of LineCollection objects corresponding to the

contour levels in cs.levels.

Eric

`

Mike Hearne wrote:

>>I don't think this is going to make it easy to do what you want

It might if I could find the x,y data in the LineCollection objects. There is an undocumented function in the LineCollection class called get_paths(), which looks like it returns a list of Path objects. These path objects have a vertices property which looks like the stuff I want. I'll explore this for a while. Anyone who knows more about these objects, feel free to chime in!

Mike,

Have you tried simply making two sets of contours, one where you have masked out the region that you want dashed, and a second with the inverse of that mask? (Or, maybe the original mask and the inverted mask should overlap so that the contours in both regions go to their common boundary.) Granted, there may be edge effects between the regions, but it should be simple and quick.

Eric

···

Thanks,

Mike

*Eric Firing <efiring@...202...>*

12/03/08 01:59 PM

To
  Mike Hearne <mhearne@...924...>
cc
  matplotlib-users@lists.sourceforge.net
Subject
  Re: [Matplotlib-users] Contour line data

Mike Hearne wrote:
>
> How can I get the actual x,y data that represents the contour lines that
> are drawn with the contour() function?
>
> I'd like to be able to redraw portions of those lines with different
> styles (dashed, dotted, etc.)
>
> For example, given the following sample code (lifted from the
> sourceforge example):
>
> from pylab import *
> from numpy import *
>
> delta = 0.025
> x = arange(-3.0, 3.0, delta)
> y = arange(-2.0, 2.0, delta)
> X, Y = meshgrid(x, y)
> Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
> Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
> # difference of Gaussians
> Z = 10.0 * (Z2 - Z1)
> figure()
> cs = plt.contour(X, Y, Z)
> show()
>
> How could I, for example, re-draw the lines in the region X [0 1] Y
> [-1.5 -0.5] as dashed?
>
> I could do it, I think, if I had the for all the lines in the plot.

I don't think this is going to make it easy to do what you want, but
cs.collections is a list of LineCollection objects corresponding to the
contour levels in cs.levels.

Eric