Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Logarithmic Color Scale in a ListContourPlot

968 views
Skip to first unread message

raul...@gmail.com

unread,
Dec 20, 2012, 3:21:26 AM12/20/12
to
Dear All,

Is it possible to use a logarithmic scale in the colour legend of a ListContourPlot?

Thank you very much in advance for any help you can provide.

Best regards,
Raul

Bob Hanlon

unread,
Dec 21, 2012, 5:38:54 AM12/21/12
to
data = Table[{
x = RandomReal[{-2, 2}],
y = RandomReal[{-2, 2}],
10^(x + 3 y/2)},
{1000}];

Module[{
min = Log[10, Min[data[[All, 3]]]],
max = Log[10, Max[data[[All, 3]]]]},
ListContourPlot[data,
PlotLegends -> Automatic,
Contours -> (Table[{2, 5, 10}*10^n,
{n, -1, 2}] // Flatten),
ColorFunction -> Function[{f},
ColorData["TemperatureMap"][(Log[10, f] - min)/(max - min)]],
ColorFunctionScaling -> False]]


Bob Hanlon

djmpark

unread,
Dec 21, 2012, 5:38:32 AM12/21/12
to
It would help if you could post a specific case illustrating the problem,
perhaps in the context of a ContourPlot so responders would have an easy
starting point.

I'm guessing that your problem is that many contour levels come out having
the same color. If that is the case you could probably use the option
ColorFunctionScaling -> False, and then write a ColorFunction that mapped
the desired actual contour values to a range of 0 to 1 using a log function.

The Presentations Application has a ContourColors ColorFunction that assures
different colors for each contour region regardless of the spacings of the
contour values.

But you can probably tailor your own ColorFunction as indicated above.


David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/index.html

raul...@gmail.com

unread,
Dec 22, 2012, 5:01:35 AM12/22/12
to
Thanks Bob, it's a great solution! I also want to thank David for the help.

Best regards,
Raul


0 new messages