Heat map + Numbers: Difference between revisions

From Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
First we write down the First Matrix, in which every number will be represented by a color
go back to [[Main Page]], [[MATHEMATICA]], [[Scripts]], [[Scripts for Mathematica 8]]
N.B. The table contains also the Axis Legend.
 
First we write down the First Matrix, in which every number will be substituted by a color
 
N.B. The table contains also the Legend.


   c1 = {
   c1 = {
         {"\!\(\*SubscriptBox[\(E\), \(sol\)]\)", "Ir", "Ru", "Sn", "Ti"},  
         {"Esol", "Ir", "Ru", "Sn", "Ti"},  
         {"\!\(\*SubscriptBox[\(IrO\), \(2\)]\)", 0.00, -0.14, 0.80, 0.37},  
         {"IrO2", 0.00, -0.14, 0.80, 0.37},  
         {"\!\(\*SubscriptBox[\(RuO\), \(2\)]\)", -0.10, 0.00, 1.03, 0.69},  
         {"RuO2", -0.10, 0.00, 1.03, 0.69},  
         {"\!\(\*SubscriptBox[\(SnO\), \(2\)]\)", 0.54, 0.43, 0.00, 0.17},  
         {"SnO2", 0.54, 0.43, 0.00, 0.17},  
         {"\!\(\*SubscriptBox[\(TiO\), \(2\)]\)", -0.71, 0.63, 0.62, 0.00}
         {"TiO2", -0.71, 0.63, 0.62, 0.00}
         }
         }


Second, we write down a Second Matrix, in which the numbers will be written over the colored tables  
Second, we write down a Second Matrix, in which the numbers will be written over the colored tables  
N.B. It's the same matrix as the first but limited to the numbers; The numbers ending with a zero have to be written between "", otherwise they will be rounded on the final figure (0.00 becomes 0.)


   c2 = {
   c2 = {
Line 18: Line 23:
         {-0.71, 0.63, 0.62, "0.00"}
         {-0.71, 0.63, 0.62, "0.00"}
         }
         }
In alternative you can import the matrix from a text file
  c1 = Import ["path/file.csv"]


Then we isolate the numerical part of the first matrix  
Then we isolate the numerical part of the first matrix  


   n1 = c1[[2 ;; All, 2 ;; All]]  
   n1 = c1[ [2;;All,2;;All] ]  


We
And we assign the variables for the Colored table


l1 = c1[[2 ;; All, 1]] (*Width of a line*)
  l1 = c1[ [2;;All,1] ]  
  p1 = c1[ [1,2;;All] ]


p1 = c1[[1, 2 ;; All]] (*Height of a column*)
Finally with the ImageCompose function, we overimpose the numbered table to the colored one


ImageCompose[
  ImageCompose[
ArrayPlot[n1, ColorFunction -> "Rainbow",  
     
  ColorFunctionScaling -> True, Frame -> True,  
      ArrayPlot[n1, ColorFunction -> "Rainbow",  
  FrameStyle -> Opacity[0], AspectRatio -> 0.737,  
        ColorFunctionScaling -> True, Frame -> True,  
  FrameTicks -> {{Transpose[{Range[Length[l1]], l1}], None}, {None,  
        FrameStyle -> Opacity[0], AspectRatio -> 0.737,  
    Transpose[{Range[Length[p1]], p1}]}},
        FrameTicks -> {{Transpose[{Range[Length[l1]], l1}], None}, {None,  
  FrameTicksStyle ->  
        Transpose[{Range[Length[p1]], p1}]}},
  Directive[Opacity[1], Bold, FontSize -> 60, FontFamily -> "Times"],
        FrameTicksStyle ->  
  Mesh -> All, MeshStyle -> White, ImageSize -> 1000],
            Directive[Opacity[1], Bold, FontSize -> 60, FontFamily -> "Times"],
GraphicsGrid[c2, BaseStyle -> {"Times", 45, Bold, White},  
        Mesh -> All, MeshStyle -> White, ImageSize -> 1000],
  AspectRatio -> 0.75, ImageSize -> 780] , {580, 310}]
     
      GraphicsGrid[c2, BaseStyle -> {"Times", 45, Bold, White},  
        AspectRatio -> 0.75, ImageSize -> 780] , {580, 310}
      ]

Latest revision as of 15:41, 6 July 2012

go back to Main Page, MATHEMATICA, Scripts, Scripts for Mathematica 8

First we write down the First Matrix, in which every number will be substituted by a color

N.B. The table contains also the Legend.

  c1 = {
       {"Esol", "Ir", "Ru", "Sn", "Ti"}, 
       {"IrO2", 0.00, -0.14, 0.80, 0.37}, 
       {"RuO2", -0.10, 0.00, 1.03, 0.69}, 
       {"SnO2", 0.54, 0.43, 0.00, 0.17}, 
       {"TiO2", -0.71, 0.63, 0.62, 0.00}
       }

Second, we write down a Second Matrix, in which the numbers will be written over the colored tables

N.B. It's the same matrix as the first but limited to the numbers; The numbers ending with a zero have to be written between "", otherwise they will be rounded on the final figure (0.00 becomes 0.)

  c2 = {
       {"0.00", -0.14, "0.80", 0.37}, 
       {"-0.10", "0.00", 1.03, 0.69}, 
       {0.54, 0.43, "0.00", 0.17}, 
       {-0.71, 0.63, 0.62, "0.00"}
       }

In alternative you can import the matrix from a text file

  c1 = Import ["path/file.csv"]

Then we isolate the numerical part of the first matrix

  n1 = c1[ [2;;All,2;;All] ] 

And we assign the variables for the Colored table

  l1 = c1[ [2;;All,1] ] 
  p1 = c1[ [1,2;;All] ] 

Finally with the ImageCompose function, we overimpose the numbered table to the colored one

  ImageCompose[
     
     ArrayPlot[n1, ColorFunction -> "Rainbow", 
        ColorFunctionScaling -> True, Frame -> True, 
        FrameStyle -> Opacity[0], AspectRatio -> 0.737, 
        FrameTicks -> {{Transpose[{Range[Length[l1]], l1}], None}, {None, 
        Transpose[{Range[Length[p1]], p1}]}},
        FrameTicksStyle -> 
           Directive[Opacity[1], Bold, FontSize -> 60, FontFamily -> "Times"],
        Mesh -> All, MeshStyle -> White, ImageSize -> 1000],
     
     GraphicsGrid[c2, BaseStyle -> {"Times", 45, Bold, White}, 
        AspectRatio -> 0.75, ImageSize -> 780] , {580, 310}
     ]