Reliefplot (imshow with shading)

Dear all,

I am using matplotlib with a great pleasure, and I enjoy its capabilities.
I have recently attended a conference where the invited speaker showed great visualizations of arrays from both experiments and simulations. His plots were basically looking like those produced by imshow, that is a luminance array rendered as a colormap image, but with the additionnal use of a shading, which gives a really great feeling to the image. You can feel the height of each part of the image.

I have tried to find what software could have produced such a plot, and found the ReliefPlot function of Mathematica, which has precisely this purpose : rendering a colormap image from an array with a shading to give the perception of relief.

The documentation and its examples are self-explanatory :
http://reference.wolfram.com/mathematica/ref/ReliefPlot.html
(look in particular at the first "neat example" at the bottom of that page)

The two "live" demonstrations illustrate this plot style quite well too :
http://demonstrations.wolfram.com/ReliefShadedElevationMap/
http://demonstrations.wolfram.com/VoronoiImage/

So here are my questions :
Is there a trick to generate an image with such a shading in matplotlib ?
If not, do you know of a python tool that could help ?
Where could I start if I want to code it myself in matplotlib ?

Thanks for your help.

Best regards,

Timothée Lecomte

···

--
Laboratoire Pierre Aigrain,
École Normale Supérieure
24, rue Lhomond
75005 Paris

Timothée Lecomte wrote:

Dear all,

I am using matplotlib with a great pleasure, and I enjoy its capabilities.
I have recently attended a conference where the invited speaker showed great visualizations of arrays from both experiments and simulations. His plots were basically looking like those produced by imshow, that is a luminance array rendered as a colormap image, but with the additionnal use of a shading, which gives a really great feeling to the image. You can feel the height of each part of the image.

I have tried to find what software could have produced such a plot, and found the ReliefPlot function of Mathematica, which has precisely this purpose : rendering a colormap image from an array with a shading to give the perception of relief.

The documentation and its examples are self-explanatory :
http://reference.wolfram.com/mathematica/ref/ReliefPlot.html
(look in particular at the first "neat example" at the bottom of that page)

The two "live" demonstrations illustrate this plot style quite well too :
http://demonstrations.wolfram.com/ReliefShadedElevationMap/
http://demonstrations.wolfram.com/VoronoiImage/

So here are my questions :
Is there a trick to generate an image with such a shading in matplotlib ?
If not, do you know of a python tool that could help ?
Where could I start if I want to code it myself in matplotlib ?

Thanks for your help.

Best regards,

Timothée Lecomte

Timothée: There is nothing built-in, but it would be a nice thing to have. Here's a proof-of-concept hack that follows the approach used in the Generic Mapping Tools (explained here http://www.seismo.ethz.ch/gmt/doc/html/tutorial/node70.html), with some code borrowed from http://www.langarson.com.au/blog/?p=14. It's very rough, but if it looks promising to you I can try to polish it.

-Jeff

hillshade.py (3.83 KB)

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg

Jeff Whitaker wrote:

Timothée Lecomte wrote:

Dear all,

I am using matplotlib with a great pleasure, and I enjoy its capabilities.
I have recently attended a conference where the invited speaker showed great visualizations of arrays from both experiments and simulations. His plots were basically looking like those produced by imshow, that is a luminance array rendered as a colormap image, but with the additionnal use of a shading, which gives a really great feeling to the image. You can feel the height of each part of the image.

I have tried to find what software could have produced such a plot, and found the ReliefPlot function of Mathematica, which has precisely this purpose : rendering a colormap image from an array with a shading to give the perception of relief.

The documentation and its examples are self-explanatory :
http://reference.wolfram.com/mathematica/ref/ReliefPlot.html
(look in particular at the first "neat example" at the bottom of that page)

The two "live" demonstrations illustrate this plot style quite well too :
http://demonstrations.wolfram.com/ReliefShadedElevationMap/
http://demonstrations.wolfram.com/VoronoiImage/

So here are my questions :
Is there a trick to generate an image with such a shading in matplotlib ?
If not, do you know of a python tool that could help ?
Where could I start if I want to code it myself in matplotlib ?

Thanks for your help.

Best regards,

Timothée Lecomte

Timothée: There is nothing built-in, but it would be a nice thing to have. Here's a proof-of-concept hack that follows the approach used in the Generic Mapping Tools (explained here http://www.seismo.ethz.ch/gmt/doc/html/tutorial/node70.html), with some code borrowed from http://www.langarson.com.au/blog/?p=14. It's very rough, but if it looks promising to you I can try to polish it.

-Jeff

Found a bug, here's a fixed version.

-Jeff

hillshade.py (3.85 KB)

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg

Jeff Whitaker wrote:

Jeff Whitaker wrote:

Timothée Lecomte wrote:

Dear all,

I am using matplotlib with a great pleasure, and I enjoy its capabilities.
I have recently attended a conference where the invited speaker showed great visualizations of arrays from both experiments and simulations. His plots were basically looking like those produced by imshow, that is a luminance array rendered as a colormap image, but with the additionnal use of a shading, which gives a really great feeling to the image. You can feel the height of each part of the image.

I have tried to find what software could have produced such a plot, and found the ReliefPlot function of Mathematica, which has precisely this purpose : rendering a colormap image from an array with a shading to give the perception of relief.

The documentation and its examples are self-explanatory :
http://reference.wolfram.com/mathematica/ref/ReliefPlot.html
(look in particular at the first "neat example" at the bottom of that page)

The two "live" demonstrations illustrate this plot style quite well too :
http://demonstrations.wolfram.com/ReliefShadedElevationMap/
http://demonstrations.wolfram.com/VoronoiImage/

So here are my questions :
Is there a trick to generate an image with such a shading in matplotlib ?
If not, do you know of a python tool that could help ?
Where could I start if I want to code it myself in matplotlib ?

Thanks for your help.

Best regards,

Timothée Lecomte

Timothée: There is nothing built-in, but it would be a nice thing to have. Here's a proof-of-concept hack that follows the approach used in the Generic Mapping Tools (explained here http://www.seismo.ethz.ch/gmt/doc/html/tutorial/node70.html), with some code borrowed from http://www.langarson.com.au/blog/?p=14. It's very rough, but if it looks promising to you I can try to polish it.

-Jeff

Found a bug, here's a fixed version.

-Jeff

Hi Jeff,

Sure it looks promising ! The example you provided is very nice. I will try on my own data on Monday, and I'll let you know if it gives a good result too. Thank you very much for that very fast hack !

Best regards,

Timothée

Timoth�e Lecomte wrote:

Jeff Whitaker wrote:

Jeff Whitaker wrote:

Timoth�e Lecomte wrote:

Dear all,

I am using matplotlib with a great pleasure, and I enjoy its capabilities.
I have recently attended a conference where the invited speaker showed great visualizations of arrays from both experiments and simulations. His plots were basically looking like those produced by imshow, that is a luminance array rendered as a colormap image, but with the additionnal use of a shading, which gives a really great feeling to the image. You can feel the height of each part of the image.

I have tried to find what software could have produced such a plot, and found the ReliefPlot function of Mathematica, which has precisely this purpose : rendering a colormap image from an array with a shading to give the perception of relief.

The documentation and its examples are self-explanatory :
http://reference.wolfram.com/mathematica/ref/ReliefPlot.html
(look in particular at the first "neat example" at the bottom of that page)

The two "live" demonstrations illustrate this plot style quite well too :
http://demonstrations.wolfram.com/ReliefShadedElevationMap/
http://demonstrations.wolfram.com/VoronoiImage/

So here are my questions :
Is there a trick to generate an image with such a shading in matplotlib ?
If not, do you know of a python tool that could help ?
Where could I start if I want to code it myself in matplotlib ?

Thanks for your help.

Best regards,

Timoth�e Lecomte

Timoth�e: There is nothing built-in, but it would be a nice thing to have. Here's a proof-of-concept hack that follows the approach used in the Generic Mapping Tools (explained here http://www.seismo.ethz.ch/gmt/doc/html/tutorial/node70.html), with some code borrowed from http://www.langarson.com.au/blog/?p=14. It's very rough, but if it looks promising to you I can try to polish it.

-Jeff

Found a bug, here's a fixed version.

-Jeff

Hi Jeff,

Sure it looks promising ! The example you provided is very nice. I will try on my own data on Monday, and I'll let you know if it gives a good result too. Thank you very much for that very fast hack !

Best regards,

Timoth�e

Timoth�e: I've added this capability in svn, along with an example (shading_example.py) to show how to use it. Thanks for suggesting it.

-Jeff

That looks awesome. Very nice work, Jeff.

Ryan

···

On Sat, Mar 14, 2009 at 8:23 AM, Jeff Whitaker <jswhit@…146…> wrote:

Timothée Lecomte wrote:

Jeff Whitaker wrote:

Jeff Whitaker wrote:

Timothée Lecomte wrote:

Dear all,

I am using matplotlib with a great pleasure, and I enjoy its

capabilities.

I have recently attended a conference where the invited speaker

showed great visualizations of arrays from both experiments and

simulations. His plots were basically looking like those produced

by imshow, that is a luminance array rendered as a colormap image,

but with the additionnal use of a shading, which gives a really

great feeling to the image. You can feel the height of each part of

the image.

I have tried to find what software could have produced such a plot,

and found the ReliefPlot function of Mathematica, which has

precisely this purpose : rendering a colormap image from an array

with a shading to give the perception of relief.

The documentation and its examples are self-explanatory :

http://reference.wolfram.com/mathematica/ref/ReliefPlot.html

(look in particular at the first “neat example” at the bottom of

that page)

The two “live” demonstrations illustrate this plot style quite well

too :

http://demonstrations.wolfram.com/ReliefShadedElevationMap/

http://demonstrations.wolfram.com/VoronoiImage/

So here are my questions :

Is there a trick to generate an image with such a shading in

matplotlib ?

If not, do you know of a python tool that could help ?

Where could I start if I want to code it myself in matplotlib ?

Thanks for your help.

Best regards,

Timothée Lecomte

Timothée: There is nothing built-in, but it would be a nice thing

to have. Here’s a proof-of-concept hack that follows the approach

used in the Generic Mapping Tools (explained here

http://www.seismo.ethz.ch/gmt/doc/html/tutorial/node70.html), with

some code borrowed from http://www.langarson.com.au/blog/?p=14.

It’s very rough, but if it looks promising to you I can try to

polish it.

-Jeff

Found a bug, here’s a fixed version.

-Jeff

Hi Jeff,

Sure it looks promising ! The example you provided is very nice. I

will try on my own data on Monday, and I’ll let you know if it gives a

good result too. Thank you very much for that very fast hack !

Best regards,

Timothée

Timothée: I’ve added this capability in svn, along with an example

(shading_example.py) to show how to use it. Thanks for suggesting it.


Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma