Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.3K Views
|
8 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Smooth heat map using ListDensityPlot of data in 6x6?

Posted 8 years ago

Hi All, Assume I have the following data and I want to plot heat map of it. Why I am not getting 6 squares for each row and for each column but getting 5 squares for each rows and columns? Any suggestion. Thanks in advanve.

data={2.18756, 2.17447, 2.17031, 2.16801, 2.31719, 2.36214, 2.14151, \
2.13749, 2.13819, 2.14531, 2.35749, 2.40783, 2.18333, 2.16507, \
2.17598, 2.21962, 3.52217, 3.60957, 2.21752, 2.14844, 2.15905, \
2.76315, 3.70188, 3.83357, 2.25902, 2.17451, 2.18496, 2.83573, \
3.6727, 3.82887, 2.23612, 2.14, 2.17541, 2.76535, 3.61427, 3.80555};

ListDensityPlot[Partition[data, 6], InterpolationOrder -> 0, 
 Mesh -> 4, PlotRange -> All, ColorFunction -> "TemperatureMap", 
 PlotLegends -> Automatic, FrameLabel -> {"IPTG", "Rib"}, 
 PlotLabel -> "Model Prediction Heat Map"]

But what I want is this

      ListDensityPlot[Partition[data, 6], InterpolationOrder -> 0, 
        Mesh -> 5, PlotRange -> All, ColorFunction -> "TemperatureMap", 
        PlotLegends -> Automatic, FrameLabel -> {"IPTG", "Rib"}, 
        PlotLabel -> "Model Prediction Heat Map"] 

Of course, for each mesh square should have unique heat color.. They are not match as you can see, it match for the first one but it is not 6x6..

Is it by default MMA gives always 5x5 ListDensityPlot when you have 6x6 data? enter image description here

I would like to get this kind of heat map if possible. I believe this pic produced using MatLab using the same data (possible transpose of data). Note that it is 6x6 squares not 5x5..

Thanks..

POSTED BY: Okkes Dulgerci
8 Replies
Posted 8 years ago

Here is what I did.

data={2.18756, 2.17447, 2.17031, 2.16801, 2.31719, 2.36214, 2.14151, \
2.13749, 2.13819, 2.14531, 2.35749, 2.40783, 2.18333, 2.16507, \
2.17598, 2.21962, 3.52217, 3.60957, 2.21752, 2.14844, 2.15905, \
2.76315, 3.70188, 3.83357, 2.25902, 2.17451, 2.18496, 2.83573, \
3.6727, 3.82887, 2.23612, 2.14, 2.17541, 2.76535, 3.61427, 3.80555};

g = ListInterpolation[data, InterpolationOrder -> 1];
data2 = g[#[[1]], #[[2]]] & /@ Tuples[Range@7, 2] // Quiet;
ListDensityPlot[Transpose@Partition[data2, 7], 
 ColorFunction -> "TemperatureMap", Frame -> True, Mesh -> 5, 
 InterpolationOrder -> 0, MeshStyle -> Black, FrameTicks -> False, 
 FrameLabel -> {"IPTG", "Rib"}, PlotLabel -> "Data Heat Map ", 
 PlotLegends -> 
  BarLegend[{"TemperatureMap", {1, 5}}, 
   LegendLabel -> 
    Placed["Fluorescence (MEPE)", Right, Rotate[#, 90 Degree] &], 
   LegendMarkerSize -> 170], ImageSize -> 200]

Which gives me exactly (more or less) ArrayPlot results. Note that data2 is 7x7 Now I can use ListDensityPlot with InterpolationOrder->1 to get 6x6 smooth heat map.

ListDensityPlot[Transpose@Partition[data2, 7], 
 ColorFunction -> "TemperatureMap", Mesh -> 5, Frame -> True, 
 InterpolationOrder -> 1, MeshStyle -> Black, FrameTicks -> False, 
 FrameLabel -> {"IPTG", "Rib"}, PlotLabel -> "Data Heat Map ", 
 PlotLegends -> 
  BarLegend[{"TemperatureMap", {1, 5}}, 
   LegendLabel -> 
    Placed["Fluorescence (MEPE)", Right, Rotate[#, 90 Degree] &], 
   LegendMarkerSize -> 170], ImageSize -> 200]

Which is what I want..

Inspared by http://stackoverflow.com/questions/31063591/in-matlab-how-to-smooth-pixels-in-2d-heatmap-using-imagesc

POSTED BY: Okkes Dulgerci
Posted 8 years ago
POSTED BY: Okkes Dulgerci
POSTED BY: Sander Huisman
Posted 8 years ago
POSTED BY: Okkes Dulgerci
POSTED BY: Sander Huisman
POSTED BY: Sander Huisman
Posted 8 years ago

Thanks Sander, that works but I realize color of ArrayPlot is more suitable. Thanks again..

ArrayPlot[Transpose@Partition[data, 6], Mesh -> 5, PlotRange -> All, 
 ColorFunctio> "TemperatureMap", PlotLegends -> Automatic, 
 FrameLabel -> {"IPTG", "Rib"}, 
 PlotLabel -> "Model Prction Heat Map", DataReversed -> True, 
 MeshStyle -> Black]
POSTED BY: Okkes Dulgerci

You could try MatrixPlot:

MatrixPlot[Partition[data, 6], Mesh -> 5, PlotRange -> All, 
 ColorFunction -> "TemperatureMap", PlotLegends -> Automatic, 
 FrameLabel -> {"IPTG", "Rib"}, 
 PlotLabel -> "Model Prediction Heat Map", DataReversed -> True]

edit, somehow ColorFunctionScaling does not work properly for me, but can be fixed like this:

{min, max} = MinMax[data]
MatrixPlot[Partition[data, 6], PlotRange -> All, 
 ColorFunction -> (ColorData["TemperatureMap"][(#1 - min)/(max - min)] &), 
 PlotLegends -> Automatic, FrameLabel -> {"IPTG", "Rib"}, 
 PlotLabel -> "Model Prediction Heat Map", DataReversed -> True, 
 ColorFunctionScaling -> False]
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard