2
$\begingroup$

I've been looking around example of rescaling color gradients but I couldn't find any workable solution for my system. I'm importing several .dat files and want to represent similar data with similar color ranges. Essentially, I'd like to rescale the color gradient start/end points to make everything consistent, where the .dat file contains a 2D array of data with z-values that should be colored the same. This is what I have so far:

color= ColorData["DeepSeaColors"];

graph = MatrixPlot[arrayData, 
   ColorFunctionScaling -> False, ColorFunction -> (cf@Rescale[#3, {200, 805}] &), 
   GridLines -> Automatic, PlotLegends -> Automatic, Frame -> False, Axes -> False, 
   Mesh -> Automatic, MeshStyle -> Black, 
   LabelStyle -> Directive @@ {FontFamily -> "Helvetica", 18, FontColor -> Black}, 
   PlotRange -> {200, 805},
   BaseStyle -> Directive @@ {FontFamily -> "Helvetica", 18, FontColor -> Black}];

Unfortunately I just get a bunch of red cubes currently!

$\endgroup$
  • 1
    $\begingroup$ Can you provide arrayData? Otherwise it is going to be guess work. $\endgroup$ – user21 Jun 23 '17 at 17:26
  • $\begingroup$ use cf@Rescale[#, {200, 805}] & instead of cf@Rescale[#3, {200, 805}] &? $\endgroup$ – kglr Jun 23 '17 at 20:13
  • $\begingroup$ I think it worked with the # rather than #3, thanks! $\endgroup$ – Bobby Jun 23 '17 at 20:46
  • $\begingroup$ @Bobby, i posted the comment as an answer. $\endgroup$ – kglr Jun 23 '17 at 21:06
2
$\begingroup$
SeedRandom[1]
arrayData = RandomInteger[{200, 805}, {10, 10}];
cf = ColorData["DeepSeaColors"];

graph = MatrixPlot[arrayData, ColorFunctionScaling -> False, 
  ColorFunction -> (cf@Rescale[#, {200, 805}] &), 
  GridLines -> Automatic, PlotLegends -> Automatic, Frame -> False, 
  Axes -> False, Mesh -> Automatic, MeshStyle -> Black, 
  LabelStyle -> Directive @@ {FontFamily -> "Helvetica", 18, FontColor -> Black}, 
  PlotRange -> {200, 805}, 
  BaseStyle -> Directive @@ {FontFamily -> "Helvetica", 18, FontColor -> Black}]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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