Heat map + legend
Jump to navigation
Jump to search
go back to Main Page, Computational Resources, MATHEMATICA, Scripts, Scripts for Mathematica 8
c1 = Import ["path/file.csv"] (*The file.csv must be in the shape matrix*)
Grid[c1] (*To see how the matrix looks like*)
n1 = c1[[2 ;; All, 2 ;; All]] (*To extract only the numerical part of the matrix *)
Grid[n1] (*To see how the numerical matrix looks like*)
l1 = c1[[2 ;; All, 1]] (*Width of a line*)
p1 = c1[[1, 2 ;; All]] (*Height of a column*)
nn1 = Rescale[#] & /@ n1 (*Rescale[n1] per line*)
(*Heat map plotted Example--> Heat_map*) ArrayPlot[nn1, ColorFunction -> "Rainbow", ColorFunctionScaling -> False, AspectRatio -> 0.9, Frame -> True, FrameStyle -> Opacity[0], FrameTicks -> {{Transpose[{Range[Length[l1]], l1}], None}, {None, Transpose[{Range[Length[p1]], Map[Rotate[#, 50 Degree] &, p1]}]}}, FrameTicksStyle -> Directive[Opacity[1], Bold, FontSize -> 22, FontFamily -> "Helvetica"], Mesh -> All, MeshStyle -> White] (*Generate lengend Example--> Legend*) q = DensityPlot[x, {x, 0, 1}, {y, 0, 0.1}, AspectRatio -> Automatic, FrameTicks -> None, ColorFunction -> "Rainbow", PlotRangePadding -> None]; l = Show[q, ImageSize -> 200, Frame -> True, FrameTicks -> {{None, None}, {{{0, Min[n1[[All, 2]]]}, {1, Max[n1[[All, 2]]]}}, None}}]
Cvargas 15:43, 13 Sept 2011