4
$\begingroup$

Consider the two table set below

t1= {0.44, 0.62, 0.77, 0.87, 0.93, 0.96, 0.98, 1}
t2= {0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25}

how can I create a plot which wil plot a rectangle with a heat map normalized to the values of the table?

The result should look like

h

$\endgroup$
  • $\begingroup$ A starting point could be: ArrayPlot[With[{n = 5}, ConstantArray[t1, n] ], ColorFunction -> "TemperatureMap"] $\endgroup$ – b.gates.you.know.what May 30 at 8:28
  • 1
    $\begingroup$ does Column[Quiet@DensityPlot[Interpolation[#][x], {x, 0, 1}, {y, 0, 1/5}, AspectRatio->Automatic,Frame -> False, PlotRangePadding->0,ImagePadding->0,ColorFunction->"Rainbow", ColorFunctionScaling->False, ImageSize->Medium]&/@{t1,t2}] give what you need? $\endgroup$ – kglr May 30 at 8:29
4
$\begingroup$

Function Blend actually does a great color interpolation. For simplicity assume that all your values are always in $[0,1]$ interval. Choose a specific Color Scheme, for example DeepSeaColors , and define:

cf[v_][x_] := Blend[ColorData["DeepSeaColors"] /@ v, x]

You do not have to use built in color schemes, you could just have assigned some colors to your numbers. The point is in blending them. Then using detailed Raster make:

Graphics[Raster[{Range[100]/100}, ColorFunction -> cf[t1]], AspectRatio -> .3]

enter image description here

Graphics[Raster[{Range[100]/100}, ColorFunction -> cf[t2]], AspectRatio -> .3]

enter image description here

It is not clear from your question how exactly you want to rescale / normalize. But you can always use Rescale to adjust the above aproach.

$\endgroup$
3
$\begingroup$
Column[Quiet @ DensityPlot[Interpolation[#][x], {x, 0, 1}, {y, 0, 1}, 
 AspectRatio -> 1/5, Frame -> False, ColorFunction -> "Rainbow", 
 ColorFunctionScaling -> False, ImageSize -> Medium] & /@ {t1, t2}]

enter image description here

$\endgroup$
2
$\begingroup$

Another idea is to use VertexColors option of Line (or Rectangle):

Graphics[
    {
    Thickness[.4],
    Line[Thread[{t1,0}], VertexColors->ColorData["DeepSeaColors"]/@t1]
    },
    AspectRatio->1/4
]

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.