Heat map + legend: Difference between revisions

From Wiki
Jump to navigation Jump to search
Cvargas (talk | contribs)
No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
go back to [[Main Page]], [[Computational Resources]], [[Scripts]], [[Scripts for Mathematica 8]]
go back to [[Main Page]], [[Computational Resources]], [[MATHEMATICA]], [[Scripts]], [[Scripts for Mathematica 8]]
 
go back to [[Main Page]], [[Computational Resources]], [[Chemistry & More]], [[Computational Codes]], [[MATHEMATICA]]


  c1 = Import ["path/file.csv"] (*The file.csv must be in the shape [[matrix]]*)
  c1 = Import ["path/file.csv"] (*The file.csv must be in the shape [[matrix]]*)
Line 18: Line 16:


  (*Heat map plotted  Example--> [[Heat_map]]*)  
  (*Heat map plotted  Example--> [[Heat_map]]*)  
   ArrayPlot[nn1, ColorFunction -> "Rainbow", ColorFunctionScaling -> False, AspectRatio -> 0.9, Frame -> True, FrameStyle -> Opacity<nowiki>[0</nowiki>],  
   ArrayPlot[nn1, ColorFunction -> "Rainbow", ColorFunctionScaling -> False, AspectRatio -> 0.9, Frame -> True, FrameStyle -> Opacity<nowiki>[0],  
   FrameTicks -> {{Transpose<nowiki>[{Range[Length[l1</nowiki>]], l1}</nowiki>], None}, {None, Transpose<nowiki>[{Range[Length[p1]], Map<nowiki>[Rotate[#, 50 Degree] &, p1]}</nowiki>]}},  
   FrameTicks -> {{Transpose[{Range[Length[l1]], l1}], None}, {None, Transpose[{Range[Length[p1]], Map[Rotate[#, 50 Degree] &, p1]}]}},  
   FrameTicksStyle -> Directive<nowiki>[Opacity[1], Bold, FontSize -> 22, FontFamily -> "Helvetica"], Mesh -> All, MeshStyle -> White</nowiki>]
   FrameTicksStyle -> Directive[Opacity[1], Bold, FontSize -> 22, FontFamily -> "Helvetica"], Mesh -> All, MeshStyle -> White</nowiki>]
 
    
    
  (*Generate lengend  Example--> [[Legend]]*)
  (*Generate lengend  Example--> [[Legend]]*)
   q = DensityPlot<nowiki>[x, {x, 0, 1}, {y, 0, 0.1}, AspectRatio -> Automatic, FrameTicks -> None, ColorFunction -> "Rainbow", PlotRangePadding -> None];
   q = DensityPlot<nowiki>[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<nowiki>[[All, 2]]]}, {1, Max[n1[[All, 2]]]}}, None}}</nowiki>]
   l = Show[q, ImageSize -> 200, Frame -> True, FrameTicks -> {{None, None}, {{{0, Min[n1[[All, 2]]]}, {1, Max[n1[[All, 2]]]}}, None}}</nowiki>]
 
 
 
 
[[User:Cvargas|Cvargas]] 15:43, 13 Sept 2011

Latest revision as of 15:38, 13 September 2011

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