1
$\begingroup$

I am using ListDensityPlot to plot data of the form {{x1,y1,z1},{x2,y2,z2}, …}. It results in the plot shown below. But I'd like to adjust the color scale contrast to better show the variations in the low-Z parts (in blue). Basically, I need more color variations for the low Z values (below ~30) and less color variations for larger values.

I've tried a log scale, but it does not show the contract sufficiently. Thanks for the help.

Here is a simplified version of the code I am using:

colorbar[{min_, max_}, colorFunction_: Automatic, divs_: 100] := DensityPlot[
  y, {x, 0, 0.2}, {y, min, max},
  PlotPoints -> {2, divs},
  ColorFunction -> colorFunction,
  AspectRatio -> 10,
  PlotRangePadding -> 0,
  MaxRecursion -> 0,
  FrameTicks -> {None, Automatic},
  FrameLabel -> {"", "Z"}];

MyData = Import["DataFileXYZ.dat", "Table"];

MyColorBar :=  Show[colorbar[
   {Min[Transpose[MyData][[3]]], Max[Transpose[MyData][[3]]]},
   "Temperature"]];

MyPlot :=  ListDensityPlot[
  MyData, 
  ColorFunction -> Function[{height}, 
  ColorData["Temperature"][height]], 
  FrameLabel -> {"X", "Y"}]

Row[Show[#, ImageSize -> {Automatic, 600}] & /@ {MyPlot, MyColorBar}]

Data file I used is here: https://www.dropbox.com/s/y1oqx8kv5o39ter/DataFileXYZ.txt?dl=0

enter image description here

$\endgroup$
4
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ Feb 11, 2015 at 20:08
  • $\begingroup$ Please provide a data sample. $\endgroup$
    – Kuba
    Feb 11, 2015 at 22:21
  • $\begingroup$ Have you tried different colour schemes? Maybe "Rainbow" or "BrightBands". Have you tried a gamma correction instead of a log? Have you tried a ListContourPlot and specify the contours you want? $\endgroup$
    – wxffles
    Feb 11, 2015 at 23:27
  • $\begingroup$ Hi @wxffles, different color schemes have the same problems. No sure how to apply a gamma correction in this case. And finally, I am already using ListContourPlot for other specific values, and I can't over crowd the plot with contours to show details in the blue part of the densityplot. Thanks for the help $\endgroup$
    – sguillot
    Feb 12, 2015 at 0:15

1 Answer 1

3
$\begingroup$

Here's how you could add a gamma correction:

Clear[gamma];
gamma[x_?NumericQ, ɣ_] := x^(1/ɣ);

MyScale = gamma[#, 4] &;

In your colorbar you plot MyScale@y and in the plot ColorFunction you have MyScale@height, and then:

1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.