4
$\begingroup$

I am trying to do the following:

Partition[Table[MatrixPlot[{{Mod[x, 30]}}, Frame -> False, ColorFunction -> "TemperatureMap", ImageSize -> 20], {x, 0, 29}], 5] // TableForm

But it outputs this:

enter image description here

I want it to consider all the colors in the spectrum of the temperature map. I tried PlotRange but it's not working. I remember there is something that forces it to do that but I can't find it.

$\endgroup$
11
$\begingroup$

1. Use the form ColorData[{"TemperatureMap", {0, 29}}] and add the option ColorFunctionScaling -> False:

Partition[
  Table[MatrixPlot[{{Mod[x, 30]}}, Frame -> False, 
    ColorFunction -> ColorData[{"TemperatureMap", {0, 29}}], 
    ColorFunctionScaling -> False, ImageSize -> 20], {x, 0, 29}], 
  5] // TableForm

enter image description here

2. Rescale the argument passed to ColorData["TemperatureMap"]:

Partition[
  Table[MatrixPlot[{{Mod[x, 30]}}, Frame -> False, 
    ColorFunction -> (ColorData["TemperatureMap"][
        Rescale[#, {0, 29}, {0, 1}]] &), 
    ColorFunctionScaling -> False, ImageSize -> 20], {x, 0, 29}], 
  5] // TableForm

enter image description here

3. Map ColorData[{"TemperatureMap", {0, 29}}] to matrix entries:

Partition[
  Table[MatrixPlot[
     {{ColorData[{"TemperatureMap", {0, 29}}] @ Mod[x, 30]}}, 
     Frame -> False, ImageSize -> 20], {x, 0, 29}], 
  5] // TableForm

enter image description here

$\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.