2) Simple Graphics: Mathematica is very useful for simple visualization of data

Reading data

ReadList["file", type] reads objects of the specified type from a file, until the end of the file is reached. The list of objects read is returned. This works well for ascii data. There is also a BinaryImport[] function for binary data.

In[21]:=

data1D = ReadList["/Users/ross/talks/mathematica/data", Number] ;

In[22]:=

Length[data1D]

Out[22]=

2500

Making data the right shape

Partition[list, n] partitions list into non-overlapping sublists of length n.

In[23]:=

Partition[{a, b, c, d}, 2]

Out[23]=

{{a, b}, {c, d}}

In[24]:=

data2D = Partition[data1D, 50] ; Length[data2D]

Out[25]=

50

Plotting data

ListPlot3D[array2D,options] generates a three-dimensional plot of a surface representing an array of height values. The option PlotRange->All is good to use.

In[26]:=

RowBox[{ListPlot3D, [, RowBox[{data2D, ,, RowBox[{ColorFunction, , RowBox[{(, RowBox[{RowBox[{Hue, [, RowBox[{0.8,  , (1 - #)}], ]}], &}], )}]}], ,, PlotRangeAll}], ]}]

[Graphics:../HTMLFiles/index_44.gif]

Out[26]=

⁃SurfaceGraphics⁃

ListDensityPlot[array2D,options] generates a density plot from a 2D array. This is useful for finite-difference results.

In[27]:=

RowBox[{RowBox[{ListDensityPlot, [, RowBox[{data2D, ,, RowBox[{ColorFunction, , RowBox ... [{Hue, [, RowBox[{0.8,  , (1 - #)}], ]}], &}], )}]}], ,, PlotRangeAll}], ]}], <br />}]

[Graphics:../HTMLFiles/index_47.gif]

Out[27]=

⁃DensityGraphics⁃

ListContourPlot[array2D,options]generates a contour plot from a 2D array. Unfortunately, you can not label the contours.

In[34]:=

RowBox[{cons, =, RowBox[{Table, [, RowBox[{c, ,, RowBox[{{, RowBox[{c, ,, RowBox[{-, 0.8}], ,, ... {RowBox[{Hue, [, RowBox[{0.8,  , (1 - #)}], ]}], &}], )}]}], ,, PlotRangeAll}], ]}]}]

Out[34]=

RowBox[{{, RowBox[{RowBox[{-, 0.8}], ,, RowBox[{-, 0.6}], ,, RowBox[{-, 0.4}], ,, RowBox[{-, 0.2}], ,, 0., ,, 0.2, ,, 0.4, ,, 0.6, ,, 0.8}], }}]

Out[35]=

RowBox[{{, RowBox[{RowBox[{{, RowBox[{Thickness, [, 0.001, ]}], }}], ,, RowBox[{{, RowBox[{Thi ...  RowBox[{Thickness, [, 0.001, ]}], }}], ,, RowBox[{{, RowBox[{Thickness, [, 0.001, ]}], }}]}], }}]

[Graphics:../HTMLFiles/index_52.gif]

Out[36]=

⁃ContourGraphics⁃

Exporting a figure

Export["file.ext", expr] exports data or graphics to a file, converting it to a format corresponding to the file extension ext.  There are many graphics types

In[37]:=

RowBox[{RowBox[{figure, =, RowBox[{ListPlot3D, [, RowBox[{data2D, ,, RowBox[{ColorFunction, &# ... ] ; Export["/Users/ross/talks/mathematica/figure.pdf", figure, ImageSize72 3] ;

[Graphics:../HTMLFiles/index_55.gif]


Created by Mathematica  (June 17, 2004)