MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Color problem with listdensityplot. Please HELP

  • To: mathgroup at
  • Subject: [mg15597] RE: [mg15552] Color problem with listdensityplot. Please HELP
  • From: "Ersek, Ted R" <ErsekTR at>
  • Date: Thu, 28 Jan 1999 04:23:27 -0500 (EST)
  • Sender: owner-wri-mathgroup at

Nick Art wrote:

I want to show a two dimensional data file as a color plot.  I'll use
the following lines:

data=ReadList("data.txt", Number, RecordLists->True];
ListDensityPlot[data, Mesh->False, PlotRange ->{-20, 20}];

My data is in the range of -20 to 20. Now I get a nice picture showing
the data in grayscale. This is not what I want. I would like to show my
data with colors in the following form:

Blue gradient below zero
Red gradient above or equal zero

so the value of -20 should be very blue, 0 should be white and 20 should
be very red with all shades of coulors in between.


You need to use the ColorFunction option. I give you an example.

The functions (all of them?) that have a ColorFunction option look at
the range of values it needs to plot and maps the range of values onto
[0,1] where the minimum value is mapped to zero and the maximum value
is mapped to 1.

Below I define a function RedToBlue that takes a number on [0,1] and
returns RGBColor[r,g,b] and will do what you want.  Then I use
ListDensityPlot to make a plot of the type you are looking for.

The only problem is that this is much slower than the default
ColorFunction. Any ideas on how to speed this up would be appreciated.

Ted Ersek

data=Table[20.0* Cos[x^2+y^2],{x,-2,2,0.05},{y,-2,2,0.05}];	



ListDensityPlot[data, Mesh -> False,

(* DensityGraphics not shown. *)

  • Prev by Date: Re: change the solution to a differential equation into a user defined function - question.nb (0/1)
  • Next by Date: Block vs. Module
  • Previous by thread: Color problem with listdensityplot. Please HELP
  • Next by thread: MathLink and RedHat 5.2