How to make colormaps

Hello,

Maybe my googling skills are deficient, but I wasn't able to find any
information on how to define my own colormap.

Can someone give me a pointer, or a basic example how to create a simple
map that e.g. maps -1 to Red, 0 to White, and 1 to Blue?

Thanks,

   -Nikolaus

···

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

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

Nikolaus Rath wrote:


Hello,
Maybe my googling skills are deficient, but I wasn't able to find any
information on how to define my own colormap.
Can someone give me a pointer, or a basic example how to create a simple
map that e.g. maps -1 to Red, 0 to White, and 1 to Blue?
Thanks,
-Nikolaus

http://lmgtfy.com/?q=matplotlib+colormaps

That was a tad harsh, given that the first page of google results
didn't really answer the question. (If you're going to be snarky, at
least make sure you're right.)

Nick, this is a pretty good example:

http://matplotlib.sourceforge.net/examples/api/colorbar_only.html

Now, since it seems like you're learning right now, a good place to
look which is better than google is searching matplotlib's docs
directly:

http://matplotlib.sourceforge.net/search.html

I was able to find that example with: codex ListedColormap
(codex tells it to search examples) but that's because I knew the name
of the class I was looking for.

Good luck and don't get discouraged.

Ryan

···

On Tue, Apr 20, 2010 at 11:40 AM, Jim Vickroy <Jim.Vickroy@...259...> wrote:

Nikolaus Rath wrote:

Hello,

Maybe my googling skills are deficient, but I wasn't able to find any
information on how to define my own colormap.

Can someone give me a pointer, or a basic example how to create a simple
map that e.g. maps -1 to Red, 0 to White, and 1 to Blue?

Thanks,

   -Nikolaus

http://lmgtfy.com/?q=matplotlib+colormaps

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

Ryan May wrote:


Nikolaus Rath wrote:
Hello,
Maybe my googling skills are deficient, but I wasn't able to find any
information on how to define my own colormap.
Can someone give me a pointer, or a basic example how to create a simple
map that e.g. maps -1 to Red, 0 to White, and 1 to Blue?
Thanks,
-Nikolaus

That was a tad harsh, given that the first page of google results
didn't really answer the question. (If you're going to be snarky, at
least make sure you're right.)
Nick, this is a pretty good example:
Now, since it seems like you're learning right now, a good place to
look which is better than google is searching matplotlib's docs
directly:
I was able to find that example with: codex ListedColormap
(codex tells it to search examples) but that's because I knew the name
of the class I was looking for.
Good luck and don't get discouraged.
Ryan

I don’t know what your Google search results page presented, but the
the second entry on the first search
results page, for me, was the following:
Cookbook/Matplotlib -
Feb 12, 2010 … Show colormaps - Small script to display all of the
Matplotlib colormaps, and an exampleshowing how to create a new
one
. …

  • Cached
    – jv
···

<Jim.Vickroy@…259…>http://lmgtfy.com/?q=matplotlib+colormapshttp://matplotlib.sourceforge.net/examples/api/colorbar_only.htmlhttp://matplotlib.sourceforge.net/search.htmlwww.scipy.org/Cookbook/Matplotlib

Nikolaus Rath wrote:

Hello,

Maybe my googling skills are deficient, but I wasn't able to find any
information on how to define my own colormap.

Can someone give me a pointer, or a basic example how to create a simple
map that e.g. maps -1 to Red, 0 to White, and 1 to Blue?

http://lmgtfy.com/?q=matplotlib+colormaps

That was a tad harsh, given that the first page of google results
didn't really answer the question. (If you're going to be snarky, at
least make sure you're right.)

Don't worry, I'm usually worse myself. And his answer did help me. I
actually googled the same query, but I skipped over the first two
matches after reading the title since I thought they'd just lead me to
examples/pylab_examples/show_colormaps.html (which I already found and
deemed to be not helpful).

Nick, this is a pretty good example:

http://matplotlib.sourceforge.net/examples/api/colorbar_only.html

If I understand correctly, this explains how to create a discrete
colormap, which isn't quite what I want. But with the two links I can
figure it out the rest, thanks to both of you!

Best,

   -Nikolaus

···

On 04/20/2010 01:06 PM, Ryan May wrote:

On Tue, Apr 20, 2010 at 11:40 AM, Jim Vickroy <Jim.Vickroy@...259...> wrote:

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

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

I don't know what your Google search results page presented, but the the
second entry on the first search results page, for me, was the following:

Cookbook/Matplotlib -
Feb 12, 2010 ... Show colormaps - Small script to display all of the
Matplotlib colormaps, and an exampleshowing how to create a new one. ...
www.scipy.org/Cookbook/Matplotlib - Cached

The way he worded it to me meant colormaps mapping certain values to
distinct colors, which was not (as far as I saw) covered by the first
two links.
It turns out I was wrong, but the point still stands: if we have new
users asking sensible questions and actually making a good effort, we
don't want to discourage them.

Now for those who want there hands held every step of the way I'm all
for snarking at.

Ryan

···

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma