-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
1/41
Data Visualization
with
Mathematica
Philadelphia Math + Science Coalitionwww.philaedfund.org/programs/advancing-education/philadelphia-math-science-
coalition
United Way Building
1709 Benjamin Franklin Parkway, Suite 700Philadelphia, PA 19103
March 8, 2010
Edward [email protected]
Goals :
To explore and dynamically interact easily with large real-time data sets visually, graphically, algebraically.Manipulate data and its creative presentation to maximize information transfer utilizing numeric, textual, and/or image representa-
tions.
2 Methods :Import[ ] function allows us to process data from personal files.
Data[ ] functions allow us to manipulate large amounts of real-world data into Mathematica from Wolfram's Integrated
Data Sources (Curated Data Sources).
Notes :With data we have values, not functions. So the data is discrete, not continuous.
In Mathematicathe data can be anything, not just numbers.
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
2/41
Mathematica
Mathematicafiles are notebooks (.NB).
Each notebook is organized by grouped cells indicated by nested brackets on the right. Cells can be collapsed/expanded.
Almost any type of object can be copied/pasted anywhere or saved as a file.
Ther are numerous types of help: palettes, application (live) documentation, online (live) documentation, support.
The documentation is live and written in Mathematica.
Deployment options:
1. Notebook Player - I can share this interactivity with anyone who does not have Mathematica. User needs to download the
free MathematicaPlayer - www.wolfram.com/products/player. The author needs to publish the notebook (.NB) into a notebook
player (.NBP) file with Wolfram Mathematica Player: Online Conversion - www.wolfram.com/solutions/interactivedeployment/publish
2. Slideshow generator via "Slide Show palette" - dynamic, live - need the free Notebook Player if you do not have Mathemat-
ica.
3. Demonstration - dynamic interactivity with Manipulate[] to create virtual manipulatives that can be hosted at Wolfram's
Demonstrations site - http://demonstrations.wolfram.com4. Can save almost anything (including cell, selections) as static RTF, PDF, HTML, TeX, TXT, PS, XML, package, GIF, JPG,
PNG, TIFF, BMP, WMF, LATEX, MathML
5. Quiz generator.
MathematicaSyntax
Mathematica is symbolic. As in all CAS (Computer Algebrais Systems], the presentation of the mathematical results may some-
times look non "traditional." Sometimes may want TraditionalForm[] or set a system preference to always display tradtional form..
[ ] function
{ } lists and sets( ) grouping
[[ ]] indexing
= assignment
== logical equal
:= function definition
x3 is a "rule," read as x gets 3
Mathematicafunctions are mixed-case and start upper-case.
Do-Loop Construct
2 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
3/41
? Table
Tableexpr, imax generates a list of imax copies of expr.Tableexpr, i, imax generates a list of the values of exprwhen i runs from 1 to imax.Tableexpr, i, imin, imax starts with i imin.Tableexpr, i, imin, imax, di uses steps di.Tableexpr, i, i1, i2, uses the successive values i1, i2, .Tableexpr, i, imin, imax, j, jmin, jmax, gives a nested list. The list associated with i is outermost.
Table 2 x 1, x, 1, 63, 5, 7, 9, 11, 13
Table x, 2 x, 2 x 5, 2 x4, x, 1, 6
1 2 7 2
2 4 9 32
3 6 11 162
4 8 13 512
5 10 15 1250
6 12 17 2592
Many more such as conditionals (if), user-defined functions.
Can program procedurally, functionally, and/or rule-based.
Built in mathematical algorithm selection is optimally chosen for problem, but can be over-ridden.
Parallel computing - within one CPU across cores and/or across CPUs - this is great for multi-core CPUs, during time-consuming
operations to allow you to do other work on the file.
MathematicaVisualization Capabilities
Looking at some visualization capbabilities. Remember that data is discrete so the Mathematica functions that utilize a mathemati-
cal function can only be used after the data is modeled with a function.
sizeImageNotebook 200;
PlotSinx, x, 0, 2 , ImageSize sizeImageNotebook
1 2 3 4 5 6
1.0
0.5
0.5
1.0
Data Visualization with Mathematica.03.nb 3
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
4/41
Plot3DSinx y2, x, 3, 3,y, 2, 2, ImageSize sizeImageNotebook
2
0
2 2
1
0
1
2
1.00.50.0
0.5
1.0
ContourPlotSinx y2, x, 3, 3,
y, 2, 2, ImageSize sizeImageNotebook
3 2 1 0 1 2 3
2
1
0
1
2
DiscretePlotPrimek, k, 1, 50, ImageSize sizeImageNotebook
10 20 30 40 50
50
100
150
200
Everything can be changed, decorated, annotated via options (PlotStyle is a graphic option) and directives. This can be easily
accessed from the "Chart Element Schemes" and the "Color Schemes"palettes.
Hover cursor over any point to be shown the data value in the tooltip.
4 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
5/41
data1 ListPlotTooltip3, 4, 5,PlotStyle PointSize0.025, Red,ImageSize sizeImageNotebook
0.5 1.0 1.5 2.0 2.5 3.0
3.5
4.0
4.5
5.0
data2 ListLinePlot3, 4, 5,PlotStyle Dashed, Magenta, ImageSize sizeImageNotebook
0.5 1.0 1.5 2.0 2.5 3.0
3.5
4.0
4.5
5.0
Can combine many graphs:
Showdata1, data2
0.5 1.0 1.5 2.0 2.5 3.0
3.5
4.0
4.5
5.0
Data Visualization with Mathematica.03.nb 5
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
6/41
ListLinePlotAccumulateRandomReal 1, 1, 250,ColorFunction "Rainbow", Filling Axis,
ImageSize sizeImageNotebook
50 100 150 200 250
5
10
15
starData TableCosk 2 Pi 7, Sink 2 Pi 7, k, 0, 21, 31 0
cos
7 sin
7 sin 3
14 cos 3
14
sin 14
cos 14
sin
14 cos
14
sin 3 14
cos 3 14
cos
7 sin
7
1 0
NstarData
1. 0.0.900969 0.433884
0.62349 0.781831
0.222521 0.974928
0.222521 0.974928
0.62349 0.781831
0.900969 0.433884
1. 0.
ListLinePlotTooltipstarData, Frame True,Axes False, ImageSize sizeImageNotebook
0.5 0.0 0.5 1.01.0
0.5
0.0
0.5
1.0
6 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
7/41
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
8/41
ParametricPlotSin2 u, Sin3 u,u, 0, 2 Pi, ImageSize sizeImageNotebook
1.0 0.5 0.5 1.0
1.0
0.5
0.5
1.0
ParametricPlotr^2 Sqrtt Cost, Sint,t, 0, 3 Pi 2, r, 1, 2, ImageSize sizeImageNotebook
6 4 2 0 2
4
2
0
2
4
8 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
9/41
ParametricPlot3D
t Cost10
, t Sint
10,
t
10,
t, 6 , 6
,
ImageSize sizeImageNotebook,
PlotStyle Thick, Red
1
0
1
1
0
1
1
0
1
ParametricPlot3D1.16^ v Cosv 1 Cosu, 1.16^ v Sinv 1 Cosu, 2 1.16^ v 1 Sinu,
u, 0, 2 Pi, v, 15, 6, Mesh None, PlotStyle Opacity0.6,PlotRange All, PlotPoints 25, ImageSize sizeImageNotebook
PolarPlotSin5 t, t, 0, , ImageSize sizeImageNotebook
0.5 0.5
0.5
0.5
1.0
Data Visualization with Mathematica.03.nb 9
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
10/41
ReliefPlotTablei Sini^2 j^2, i, 4, 4, .03, j, 4, 4, .03,ColorFunction "SunsetColors", ImageSize sizeImageNotebook
GraphPlotTablei Modi^2, 102, i, 0, 102
A 100-node random graph with 1% of possible edges filled in:
10 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
11/41
GraphPlotRandomChoice0.01, 0.99 1, 0, 100, 100
Layered graphs.
LayeredGraphPlot1 2, 1 3, 2 3, 1 4, 2 4, 1 5,VertexLabeling True, ImageSize sizeImageNotebook
1
2
3 4
5
Data Visualization with Mathematica.03.nb 11
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
12/41
LayeredGraphPlot"John" "plants", "lion" "John", "tiger" "John",
"tiger" "deer", "lion" "deer", "deer" "plants",
"mosquito" "lion", "frog" "mosquito", "mosquito" "tiger",
"John" "cow", "cow" "plants", "mosquito" "deer","mosquito" "John", "snake" "frog", "vulture" "snake",
Left, VertexLabeling True, ImageSize 700
Johnlion
tiger deer
mosquitofrog
cow
snakevulture
And many more:
ListPlot, DateListPlot, ListLogPlot,
RegionPlot, RegionPlot3D, DensityPlot, ListDensityPlot, ContourPlot, ArrayPlot, RegionPlot, StreamPlot, VectorPlot, StreamDensi-
tyPlot, VectordensityPlot,
StreamPlot VectorPlot StreamDensityPlot VectorDensityPlot
RevolutionPlot3D, ParametricPlot3D, TreePlot
Import [ ] and Fitting Model to Data
Import and Export can handle not only tabular data, but also data corresponding to graphics, sounds, expressions and even
whole documents. Import and Export can often deduce the appropriate format for data simply by looking at the extension of the
file name for the file in which the data is being stored. "Exporting Graphics and Sounds" and "Importing and Exporting Files" discuss
in more detail how Import and Export work. Note that you can also use Import and Export to manipulate raw files of binary
data.
12 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
13/41
$ImportFormats
3DS, ACO, AIFF, ApacheLog, AU, AVI, Base64, Binary, Bit, BMP, Byte, BYU, BZIP2, CDED, CDF, Character16, Character8,Complex128, Complex256, Complex64, CSV, CUR, DBF, DICOM, DIF, Directory, DXF, EDF, ExpressionML, FASTA, FITS,
FLAC, GenBank, GeoTIFF, GIF, Graph6, GTOPO30, GZIP, HarwellBoeing, HDF, HDF5, HTML, ICO, Integer128, Integer16,
Integer24, Integer32, Integer64, Integer8, JPEG, JPEG2000, JVX, LaTeX, List, LWO, MAT, MathML, MBOX, MDB, MGF,
MMCIF, MOL, MOL2, MPS, MTP, MTX, MX, NB, NetCDF, NOFF, OBJ, ODS, OFF, Package, PBM, PCX, PDB, PDF,
PGM, PLY, PNG, PNM, PPM, PXR, QuickTime, RawBitmap, Real128, Real32, Real64, RIB, RSS, RTF, SCT, SDF, SDTS,
SDTSDEM, SHP, SMILES, SND, SP3, Sparse6, STL, String, SXC, Table, TAR, TerminatedString, Text, TGA, TIFF, TIGER,
TSV, UnsignedInteger128, UnsignedInteger16, UnsignedInteger24, UnsignedInteger32, UnsignedInteger64, UnsignedInteger8,
USGSDEM, UUE, VCF, WAV, Wave64, WDX, XBM, XHTML, XHTMLMathML, XLS, XML, XPORT, XYZ, ZIP
$ExportFormats
3DS, ACO, AIFF, AU, AVI, Base64, Binary, Bit, BMP, Byte, BYU, BZIP2, CDF, Character16, Character8, Complex128,Complex256, Complex64, CSV, DICOM, DIF, DXF, EMF, EPS, ExpressionML, FASTA, FITS, FLAC, FLV, GIF, Graph6,
GZIP, HarwellBoeing, HDF, HDF5, HTML, Integer128, Integer16, Integer24, Integer32, Integer64, Integer8, JPEG,
JPEG2000, JVX, List, LWO, MAT, MathML, Maya, MGF, MIDI, MOL, MOL2, MTX, MX, NB, NetCDF, NOFF, OBJ,
OFF, Package, PBM, PCX, PDB, PDF, PGM, PLY, PNG, PNM, POV, PPM, PXR, RawBitmap, Real128, Real32, Real64,
RIB, RTF, SCT, SDF, SND, Sparse6, STL, String, SVG, SWF, Table, TAR, TerminatedString, TeX, Text, TGA, TIFF, TSV,
UnsignedInteger128, UnsignedInteger16, UnsignedInteger24, UnsignedInteger32, UnsignedInteger64, UnsignedInteger8,
UUE, VRML, WAV, Wave64, WDX, WMF, X3D, XBM, XHTML, XHTMLMathML, XLS, XML, XYZ, ZIP, ZPR
? Import
Import"file" imports data from a file, returning a complete Mathematica version of it.Import"file", elements imports the specified elements from a file.Import"http:url", and Import"ftp:url", imports from any accessible URL.
?Fit
Fitdata, funs, vars finds a least-squares fit toa list of data as a linear combination of the functions funs of variables vars.
? FindFit
FindFitdata, expr, pars, vars finds numerical values of the parameters pars that make exprgive abest fit to data as a function of vars. The data can have the form x1, y1, , f1, x2, y2, , f2, ,where the number of coordinates x, y, is equal to the number of variables in the list vars. The
data can also be of the form
f
1, f
2,
, with a single coordinate assumed to take values 1, 2, .
FindFitdata, expr, cons, pars, vars finds a best fit subject to the parameter constraints cons.
$DataDirectory ToFileNameNotebookDirectory, "Data";
Data Visualization with Mathematica.03.nb 13
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
14/41
$DataDirectory
J:\presentations\Data Visualization with Mathematica\Data\
AppendTo$Path, $DataDirectory;$Path
C:\Program Files\Wolfram Research\Mathematica\7.0\SystemFiles\Links,C:\Documents and Settings\Ed\Application Data\Mathematica\Kernel,
C:\Documents and Settings\Ed\Application Data\Mathematica\Autoload,
C:\Documents and Settings\Ed\Application Data\Mathematica\Applications,
C:\Documents and Settings\All Users\Application Data\Mathematica\Kernel,
C:\Documents and Settings\All Users\Application Data\Mathematica\Autoload,
C:\Documents and Settings\All Users\Application Data\Mathematica\Applications, .,
C:\Documents and Settings\Ed, C:\Program Files\Wolfram Research\Mathematica\7.0\AddOns\Packages,
C:\Program Files\Wolfram Research\Mathematica\7.0\AddOns\LegacyPackages,
C:\Program Files\Wolfram Research\Mathematica\7.0\SystemFiles\Autoload,
C:\Program Files\Wolfram Research\Mathematica\7.0\AddOns\Autoload,
C:\Program Files\Wolfram Research\Mathematica\7.0\AddOns\Applications,
C:\Program Files\Wolfram Research\Mathematica\7.0\AddOns\ExtraPackages,
C:\Program Files\Wolfram Research\Mathematica\7.0\SystemFiles\Kernel\Packages,
C:\Program Files\Wolfram Research\Mathematica\7.0\Documentation\English\System,
J:\presentations\Data Visualization with Mathematica\Data\
Fitting a model to a series of (x,y) data values:
dataLinear Import"data.xls", "Data", 1;dataPlotLinear
ListPlotTooltipdataLinear, PlotStyle PointSize0.02, Green
2 4 6 8 10
30
40
50
Fit the data to the model a x b.
14 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
15/41
Clear a, b;fitLinear FindFitdataLinear, a x b, a, b, x
a 4.61415, b 8.924
Display the fit function together with the data.
ShowdataPlotLinear,Plota x b . fitLinear, x, 0, 10, PlotStyle Red
2 4 6 8 10
30
40
50
Fitting non-linear data.
dataNoisy Import
"noisydata.xls",
"Data", 1
;
dataNoisyPlot ListPlotdataNoisy
1 2 3 4 5 6
1.0
0.5
0.5
1.0
Fit the data to the model sinx sin x.
fit FindFitdataNoisy, Sin x Sin x, , , , , x 0.00718779, 1.00277, 1.41681, 0.999737
Data Visualization with Mathematica.03.nb 15
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
16/41
Display the fit function together with the data.
ShowdataNoisyPlot,Plot Sin x Sin x . fit, x, 0, 6.3, PlotStyle Red
1 2 3 4 5 6
1.0
0.5
0.5
1.0
The next example fits a nonlinear model to some astronomical data.
This imports a data file consisting of timing residuals for the pulsar PSR1257+12 spanning a three-year period (kindly supplied by
Alex Wolszczan).
dataPulsar Import"pulsar1257.dat", "Table";Display the pulsar data:
dataPulsar
0.687021 0.0188495
0.719811 0.335115
0.730804 0.52507
0.796315 0.257191
0.845486 2.15298
0.861925 2.10726
0.952068 2.59551
0.95484 2.62171
0.973977 2.32315
0.976714 2.22064
1.20073 0.568935
16 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
17/41
. .
1.30188 0.488403
1.30455 0.494481
1.31002 0.469674
1.39201 1.94947
1.39477 1.97185
1.44655 0.0107999
1.44664 0.00668151.55317 0.0770058
1.55587 0.128978
1.59684 2.46479
1.59966 2.52511
1.63513 1.86379
1.67874 0.689795
1.68151 0.815304
1.6897 1.12602
1.70062 1.37461
1.71974 1.37764
1.76346 0.223993
1.76619 0.155781
1.80171 0.231833
1.80456 0.218089
1.80735 0.19759
1.82358 0.02412
1.82634 0.0089064
1.8509 0.22583
1.85364 0.222086
1.86456 0.150962
1.88094 0.176626
1.88366 0.253788
1.90829 1.07285
1.91101 1.16397
1.91379 1.24854
1.91918 1.40647
1.92192 1.469481.96838 1.15017
1.99029 0.019696
2.06935 1.89477
2.12112 1.7299
2.13467 2.39416
2.15652 2.67063
2.15925 2.63692
2.18661 1.47038
2.19189 1.12811
2.19464 0.939938
2.26282 1.63623
Data Visualization with Mathematica.03.nb 17
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
18/41
. .
2.30105 0.467178
2.3038 0.370373
2.30653 0.27104
2.30923 0.185139
2.31196 0.100059
2.31473 0.0191635
2.31741 0.06136372.32012 0.135984
2.32288 0.193437
2.32562 0.262972
2.33105 0.3573
2.3336 0.386537
2.38549 0.108196
2.3882 0.0782136
2.41802 0.0979297
2.41909 0.116686
2.4208 0.139112
2.49979 1.2944
2.50256 1.23173
2.55708 1.44589
2.55979 1.583872.57344 2.143
2.57619 2.21118
2.66331 1.77407
2.66602 1.93837
2.72048 2.01038
2.7232 1.85777
2.75059 0.0428941
2.75592 0.405188
2.75867 0.595059
2.78859 1.85679
2.79134 1.89844
2.83763 0.804781
2.84038 0.68503
2.87312 0.49313
2.87584 0.550665
2.91669 0.564317
2.96028 0.154039
2.96302 0.17036
3.02575 1.16419
3.02851 1.17307
3.08589 0.619972
3.08867 0.764877
3.12139 2.11591
3.1706 0.76415
3.17332 0.576337
18 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
19/41
3.23625 2.80614
3.2389 2.80191
3.26894 1.70996
3.2717 1.52628
3.27441 1.34718
3.27716 1.15426
3.27988 0.958417
3.2826 0.752647
3.28539 0.542753
3.28809 0.337932
3.29353 0.0750401
3.29624 0.274558
3.299 0.47054
3.30172 0.667524
3.30445 0.851145
3.30719 1.02325
3.31267 1.34591
3.3154 1.48888
3.31809 1.61345
3.32085 1.73499
3.3263 1.919163.32906 1.9923
3.33182 2.04945
3.33455 2.09106
3.38369 0.774774
3.38643 0.647009
3.43013 0.938914
3.4312 0.951182
3.43291 0.967501
3.47933 0.531234
3.48206 0.479443
3.52028 0.222164
3.54214 0.516191
3.54486 0.560826
3.55033 0.649746
3.55852 0.771456
3.56671 0.857604
3.56947 0.87025
3.57219 0.882395
3.57496 0.889598
3.58044 0.873126
3.58584 0.832191
3.5886 0.800181
3.5914 0.757595
3.59404 0.708435
3.59676 0.654172
Data Visualization with Mathematica.03.nb 19
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
20/41
3.59952 0.585253
3.60227 0.513836
3.60496 0.43218
3.60775 0.345518
3.6241 0.303461
3.62692 0.430591
3.63231 0.679269
3.63502 0.809463
3.63778 0.929009
3.64049 1.05495
3.64323 1.18237
3.64596 1.30095
3.65144 1.5187
3.65414 1.6279
3.65689 1.70974
3.65962 1.79757
3.66236 1.87084
3.6651 1.93
3.71426 0.703003
3.71701 0.515862
3.76086 2.36768
3.76342 2.46275
dataPulsarPlot
ListPlotdataPulsar, AspectRatio 12
, PlotStyle Red
1.5 2.0 2.5 3.0 3.5
2
1
1
2
3
Here is the nonlinear model we will use for the fit.
+ cos(t ) + cos(t ) + sin(t ) + sin(t )
This computes the regression using nondefault starting values for the parameters.
params FindFit
dataPulsar,
Sin t Cos t Sin t Cos t ,, 1, , 1, , 1, , 0, , 23.31, , 34.64, , 0, t
0.46115, 1.33261, 1.29803, 0.209533, 23.3869, 34.5111, 0.0769581
This plot shows the quality of the nonlinear fit.
20 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
21/41
ShowPlot Sin t Cos t Sin t Cos t . params,t, 0.68, 3.76,
dataPulsarPlot
1.5 2.0 2.5 3.0 3.5
2
1
1
2
xxxxData[] - Curated Data Sources - Integrated Data Sources - What Kind of Data Collections?
xxxxData functions :An efficient load-on-demand mechanism makes hundreds of gigabytes of carefully curated and continually updated data immedi-
ately available inside Mathematica for use in computations. This data, curated at Wolfram Research, can be accessed and pro-
cessed in a coherent way.
These data functions cover:
math, science, politics, geography, finance, ...
Examples include:
LatticeData,
WeatherData,
Physical and chemical data: ElementData, ChemicalData, IsotopeData, ParticleData,
Earth and astronomical data: WeatherData, GeodesyData, CityData, CountryData, GeoDistance, AstronomicalData,
Life science data: GenomeData, GenomeLookup, SequenceAlignment, ProteinData,
Finance and economic data: FinancialData, CountryData,
Mathematical data: FiniteGroupData, GraphData, KnotData, LatticeData, PolyhedronData,
Linguistic data: DictionaryLookup, WordData, ExampleData,
ProteinData"prot" gives the reference amino acid sequence for the protein prot.ProteinData"prot", "property" gives the value of the specified property for the protein prot.
Data Visualization with Mathematica.03.nb 21
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
22/41
What Kind of Data and Meta-Data within Collection?
? ElementData
ElementData"name", "property" gives the value of the specified property for the chemical element "name".ElementDatan, "property" gives the specified property for the nth chemical element.
List the ElementData[] collections:
ElementDataHydrogen, Helium, Lithium, Beryllium, Boron, Carbon, Nitrogen, Oxygen, Fluorine, Neon, Sodium, Magnesium, Aluminum, Silicon,
Phosphorus, Sulfur, Chlorine, Argon, Potassium, Calcium, Scandium, Titanium, Vanadium, Chromium, Manganese, Iron,
Cobalt, Nickel, Copper, Zinc, Gallium, Germanium, Arsenic, Selenium, Bromine, Krypton, Rubidium, Strontium, Yttrium,
Zirconium, Niobium, Molybdenum, Technetium, Ruthenium, Rhodium, Palladium, Silver, Cadmium, Indium, Tin, Antimony,
Tellurium, Iodine, Xenon, Cesium, Barium, Lanthanum, Cerium, Praseodymium, Neodymium, Promethium, Samarium,
Europium, Gadolinium, Terbium, Dysprosium, Holmium, Erbium, Thulium, Ytterbium, Lutetium, Hafnium, Tantalum, Tungsten,
Rhenium, Osmium, Iridium, Platinum, Gold, Mercury, Thallium, Lead, Bismuth, Polonium, Astatine, Radon, Francium, Radium,
Actinium, Thorium, Protactinium, Uranium, Neptunium, Plutonium, Americium, Curium, Berkelium, Californium, Einsteinium,
Fermium, Mendelevium, Nobelium, Lawrencium, Rutherfordium, Dubnium, Seaborgium, Bohrium, Hassium, Meitnerium,
Darmstadtium, Roentgenium, Ununbium, Ununtrium, Ununquadium, Ununpentium, Ununhexium, Ununseptium, Ununoctium
ElementData1Hydrogen
LengthElementData118
ElementData"Properties"Abbreviation, AbsoluteBoilingPoint, AbsoluteMeltingPoint, AdiabaticIndex, AllotropeNames, AllotropicMultiplicities, AlternateNames,
AlternateStandardNames, AtomicNumber, AtomicRadius, AtomicWeight, Block, BoilingPoint, BrinellHardness, BulkModulus,
CASNumber, Color, CommonCompoundNames, CovalentRadius, CriticalPressure, CriticalTemperature, CrustAbundance,
CrystalStructure, CuriePoint, DecayMode, Density, DiscoveryCountries, DiscoveryYear, ElectricalConductivity, ElectricalType,
ElectronAffinity, ElectronConfiguration, ElectronConfigurationString, Electronegativity, ElectronShellConfiguration,
FusionHeat, GasAtomicMultiplicities, Group, HalfLife, HumanAbundance, IconColor, IonizationEnergies, IsotopeAbundances,
KnownIsotopes, LatticeAngles, LatticeConstants, Lifetime, LiquidDensity, MagneticType, MassMagneticSusceptibility,
MeltingPoint, Memberships, MeteoriteAbundance, MohsHardness, MolarMagneticSusceptibility, MolarVolume, Name,
NeelPoint, NeutronCrossSection, NeutronMassAbsorption, OceanAbundance, Period, Phase, PoissonRatio, QuantumNumbers,
Radioactive, RefractiveIndex, Resistivity, ShearModulus, SolarAbundance, SoundSpeed, SpaceGroupName, SpaceGroupNumber,
SpecificHeat, StableIsotopes, StandardName, SuperconductingPoint, ThermalConductivity, ThermalExpansion, UniverseAbundance,
Valence, VanDerWaalsRadius, VaporizationHeat, VickersHardness, VolumeMagneticSusceptibility, YoungModulus
ElementData can be indexed by full name, number, or abbreviation:
22 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
23/41
ElementData"Hydrogen", "MeltingPoint"259.14
ElementData1, "MeltingPoint"259.14
ElementData"H", "MeltingPoint"259.14
What are the units of Hydrogen's MeltingPoint?
ElementData"H", "MeltingPoint", "Units"DegreesCelsius
ElementData"H", "MeltingPoint", "UnitsNotation"C
Sample Visualization Development
? ListLinePlot
ListLinePloty1, y2, plots a line through a list of values, assumed to correspond to x coordinates 1, 2, .ListLinePlotx1, y1, x2, y2, plots a line through specific x and y positions.ListLinePlotlist1, list2, plots several lines.
TableElementDataz, "MeltingPoint", z, 1, 118259.14, , 180.54, 1287., 2075., 3550., 210.1, 218.3, 219.6, 248.59, 97.72, 650., 660.32, 1414., 44.2, 115.21, 101.5, 189.3,
63.38, 842., 1541., 1668., 1910., 1907., 1246., 1538., 1495., 1455., 1084.62, 419.53, 29.76, 938.3, 817., 221., 7.3, 157.36,
39.31, 777., 1526., 1855., 2477., 2623., 2157., 2334., 1964., 1554.9, 961.78, 321.07, 156.6, 231.93, 630.63, 449.51, 113.7, 111.8,
28.44, 727., 920., 798., 931., 1021., 1.1 10
3
, 1072., 822., 1313., 1356., 1412., 1474., 1497., 1545., 819., 1663., 2233., 3017.,3422., 3186., 3033., 2466., 1768.3, 1064.18, 38.83, 304., 327.46, 271.3, 254., 302., 71., , 7.0 102, 1050., 1750., 1572.,
1135., 644., 640., 1176., 1345., 1050., 900., 860., 1527., 827., 827., 1627., , , , , , , , , , , , , , ,
Data Visualization with Mathematica.03.nb 23
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
24/41
ListLinePlotTableElementDataz, "MeltingPoint", z, 1, 118
20 40 60 80 100
500
1000
1500
2000
2500
3000
3500
? ListPlot
ListPloty1, y2, plots points corresponding to a list of values, assumed to correspond to x coordinates 1, 2, .ListPlotx1, y1, x2, y2, plots a list of points with specified x and y coordinates.ListPlotlist1, list2, plots several lists of points.
ListPlotTableElementDataz, "MeltingPoint", z, 1, 118
20 40 60 80 100
500
1000
1500
2000
2500
3000
3500
TableElementDataz, "MeltingPoint", z, 118259.14, , 180.54, 1287., 2075., 3550., 210.1, 218.3, 219.6, 248.59, 97.72, 650., 660.32, 1414., 44.2, 115.21, 101.5, 189.3,
63.38, 842., 1541., 1668., 1910., 1907., 1246., 1538., 1495., 1455., 1084.62, 419.53, 29.76, 938.3, 817., 221., 7.3, 157.36,
39.31, 777., 1526., 1855., 2477., 2623., 2157., 2334., 1964., 1554.9, 961.78, 321.07, 156.6, 231.93, 630.63, 449.51, 113.7, 111.8,
28.44, 727., 920., 798., 931., 1021., 1.1 103, 1072., 822., 1313., 1356., 1412., 1474., 1497., 1545., 819., 1663., 2233., 3017.,
3422., 3186., 3033., 2466., 1768.3, 1064.18, 38.83, 304., 327.46, 271.3, 254., 302., 71., , 7.0 102, 1050., 1750., 1572.,
1135., 644., 640., 1176., 1345., 1050., 900., 860., 1527., 827., 827., 1627., , , , , , , , , , , , , , ,
dataMeltingPointElement
TableElementDataz, "MeltingPoint", ElementDataz, z, 118
24 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
25/41
259.14 Hydrogen
Helium
180.54 Lithium
1287. Beryllium
2075. Boron
3550. Carbon
210.1 Nitrogen
218.3 Oxygen
219.6 Fluorine
248.59 Neon
97.72 Sodium
650. Magnesium
660.32 Aluminum
1414. Silicon
44.2 Phosphorus
115.21 Sulfur
101.5 Chlorine
189.3 Argon
63.38 Potassium
842. Calcium
1541. Scandium
1668. Titanium
1910. Vanadium
1907. Chromium
1246. Manganese
1538. Iron
1495. Cobalt
1455. Nickel
1084.62 Copper
419.53 Zinc
29.76 Gallium
938.3 Germanium
817. Arsenic
221. Selenium
7.3 Bromine
157.36 Krypton
Data Visualization with Mathematica.03.nb 25
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
26/41
39.31 Rubidium
777. Strontium
1526. Yttrium
1855. Zirconium
2477. Niobium
2623. Molybdenum
2157. Technetium
2334. Ruthenium
1964. Rhodium
1554.9 Palladium
961.78 Silver
321.07 Cadmium
156.6 Indium
231.93 Tin
630.63 Antimony
449.51 Tellurium
113.7 Iodine
111.8 Xenon
28.44 Cesium
727. Barium
920. Lanthanum798. Cerium
931. Praseodymium
1021. Neodymium
1.1 103 Promethium
1072. Samarium
822. Europium
1313. Gadolinium
1356. Terbium
1412. Dysprosium
1474. Holmium
1497. Erbium
1545. Thulium
819. Ytterbium
1663. Lutetium
2233. Hafnium
3017. Tantalum
3422. Tungsten
3186. Rhenium
3033. Osmium
2466. Iridium
1768.3 Platinum
1064.18 Gold
38.83 Mercury
304. Thallium
327.46 Lead
26 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
27/41
271.3 Bismuth
254. Polonium
302. Astatine
71. Radon
Francium
7.0 102 Radium
1050. Actinium
1750. Thorium
1572. Protactinium
1135. Uranium
644. Neptunium
640. Plutonium
1176. Americium
1345. Curium
1050. Berkelium
900. Californium
860. Einsteinium
1527. Fermium
827. Mendelevium
827. Nobelium
1627. Lawrencium Rutherfordium
Dubnium
Seaborgium
Bohrium
Hassium
Meitnerium
Darmstadtium
Roentgenium
Ununbium
Ununtrium
Ununquadium
Ununpentium
Ununhexium
Ununseptium
Ununoctium
? Dimensions
Dimensionsexpr gives a list of the dimensions of expr.Dimensionsexpr, n gives a list of the dimensions of exprdown to level n.
DimensionsdataMeltingPointElement
118, 2
LengthdataMeltingPointElement118
Data Visualization with Mathematica.03.nb 27
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
28/41
dataMeltingPointElement1259.14, Hydrogen
dataMeltingPointElement12Hydrogen
ListLinePlotTableElementDataz, "MeltingPoint", z, 1, 118
20 40 60 80 100
500
1000
1500
2000
2500
3000
3500
28 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
29/41
ListLinePlotTooltipTableElementDataz, "MeltingPoint", z, 1, 118,PlotLabel "Melting Point vs Atomic Number",
AxesLabel "Atomic\nNumber", "Melting\nPoint C",LabelStyle DirectiveBlue, Bold, GridLines Automatic
20 40 60 80
500
1000
1500
2000
2500
3000
3500
Melting
Point C
Melting Point vs Atomic Number
dataMpBp TableElementDataz, "MeltingPoint",ElementDataz, "BoilingPoint", z, 1, 118;
Data Visualization with Mathematica.03.nb 29
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
30/41
ListLinePlotdataMpBp
500 1000 1500 2000 2500 3000 3500
1000
2000
3000
4000
5000
ListPlotdataMpBp
500 1000 1500 2000 2500 3000 3500
1000
2000
3000
4000
5000
The data points can have tool tips with information when the mouse hovers over a data point.
? Tooltip
Tooltipexpr, label displays label as a tooltip while the mouse pointer is in the area where expr is displayed.
30 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
31/41
ListPlotTooltipdataMpBp
500 1000 1500 2000 2500 3000 3500
1000
2000
3000
4000
5000
ElementData"Properties"
Abbreviation, AbsoluteBoilingPoint, AbsoluteMeltingPoint, AdiabaticIndex, AllotropeNames, AllotropicMultiplicities, AlternateNames,AlternateStandardNames, AtomicNumber, AtomicRadius, AtomicWeight, Block, BoilingPoint, BrinellHardness, BulkModulus,
CASNumber, Color, CommonCompoundNames, CovalentRadius, CriticalPressure, CriticalTemperature, CrustAbundance,
CrystalStructure, CuriePoint, DecayMode, Density, DiscoveryCountries, DiscoveryYear, ElectricalConductivity, ElectricalType,
ElectronAffinity, ElectronConfiguration, ElectronConfigurationString, Electronegativity, ElectronShellConfiguration,
FusionHeat, GasAtomicMultiplicities, Group, HalfLife, HumanAbundance, IconColor, IonizationEnergies, IsotopeAbundances,
KnownIsotopes, LatticeAngles, LatticeConstants, Lifetime, LiquidDensity, MagneticType, MassMagneticSusceptibility,
MeltingPoint, Memberships, MeteoriteAbundance, MohsHardness, MolarMagneticSusceptibility, MolarVolume, Name,
NeelPoint, NeutronCrossSection, NeutronMassAbsorption, OceanAbundance, Period, Phase, PoissonRatio, QuantumNumbers,
Radioactive, RefractiveIndex, Resistivity, ShearModulus, SolarAbundance, SoundSpeed, SpaceGroupName, SpaceGroupNumber,
SpecificHeat, StableIsotopes, StandardName, SuperconductingPoint, ThermalConductivity, ThermalExpansion, UniverseAbundance,
Valence, VanDerWaalsRadius, VaporizationHeat, VickersHardness, VolumeMagneticSusceptibility, YoungModulus
dataMpBp2 TableElementDataz, "MeltingPoint",ElementDataz, "BoilingPoint", z, 1, 118
259.14 252.87
268.93
180.54 1342.
1287. 2470.
2075. 4000.
3550. 4027.
210.1 195.79
Data Visualization with Mathematica.03.nb 31
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
32/41
. .
219.6 188.12
248.59 246.08
97.72 883.
650. 1090.
660.32 2519.
1414. 2.9 103
44.2 280.5115.21 444.72
101.5 34.04
189.3 185.8
63.38 759.
842. 1484.
1541. 2830.
1668. 3287.
1910. 3407.
1907. 2671.
1246. 2061.
1538. 2861.
1495. 2927.
1455. 2913.
1084.62 2927.
419.53 907.
29.76 2204.
938.3 2820.
817. 614.
221. 685.
7.3 59.
157.36 153.22
39.31 688.
777. 1382.
1526. 3345.
1855. 4409.
2477. 4744.
2623. 4639.2157. 4265.
2334. 4150.
1964. 3695.
1554.9 2963.
961.78 2162.
321.07 767.
156.6 2072.
231.93 2602.
630.63 1587.
449.51 988.
113.7 184.3
32 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
33/41
. .
28.44 671.
727. 1870.
920. 3464.
798. 3360.
931. 3290.
1021. 3.1 103
1.1 103 3.0 103
1072. 1803.
822. 1527.
1313. 3250.
1356. 3230.
1412. 2567.
1474. 2700.
1497. 2868.
1545. 1950.
819. 1196.
1663. 3402.
2233. 4603.
3017. 5458.
3422. 5555.
3186. 5596.
3033. 5012.
2466. 4428.
1768.3 3825.
1064.18 2856.
38.83 356.73
304. 1473.
327.46 1749.
271.3 1564.
254. 962.
302.
71. 61.7
7.0 102
1737.1050. 3200.
1750. 4820.
1572. 4000.
1135. 3927.
644. 4.0 103
640. 3230.
1176. 2011.
1345. 3110.
1050.
900.
860.
Data Visualization with Mathematica.03.nb 33
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
34/41
1527.
827.
827.
1627.
Creating a Dynamic Interactive Manipulative to Huge Data Set
ManipulateplotTypeTable
ElementDataz, prop1, ElementDataz, prop2, z, 1, 118,plotType, ListPlot, ListLinePlot,
ListLogPlot, ListLogLinearPlot,prop1, ElementData"Properties",prop2, ElementData"Properties"
34 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
35/41
plotType ListPlot ListLinePlot ListLogPlot ListLogLinearPlot
prop1 AtomicNumber
prop2 AtomicRadius
20 40 60 80
100
150
200
250
300
Capabilities - Only the Beginning
Plot the closing prices for Google stock since its initial public offering on August 19, 2004.
DateListPlotTooltipFinancialData"GOOG", "August 19 2004", Joined True
2005 2006 2007 2008 2009 2010
100
200
300
400
500
600
700
This creates a plot comparing the closing stock price over the year 2006 for three companies: General Electric, Akamai, and
Microsoft.
Data Visualization with Mathematica.03.nb 35
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
36/41
DateListPlotTooltipFinancialData"GE", "2006", FinancialData"AKAM", "2006",
FinancialData"MSFT", "2006", Joined True
2006 2007 2008 2009 2010
10
20
30
40
50
60
AstronomicalData"Earth", "Image"
TooltipAstronomicalData, "Image",AstronomicalData, "Name" & AstronomicalData"Planet"
Make a graphic of solar system orbit paths with tooltips displaying images of each planet.
36 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
37/41
Graphics3DLightGray, TooltipAstronomicalData, "OrbitPath",AstronomicalData, "Image" &
AstronomicalData"Planet", Background Black
Varying distance of planets from Earth in 2009:
AstronomicalData"Earth", "Distance", "Units"Meters
DateListPlotTooltipTableDateList2009, 1, i, AstronomicalData,
"Distance", DateList2009, 1, i, i, 1, 365.25, 10, & "Mercury", "Venus", "Mars", "Jupiter", "Saturn",
Joined True, GridLines Automatic
Jan Apr Jul Oct Jan
0
5.0 1011
1.0 1012
1.5 1012
Data Visualization with Mathematica.03.nb 37
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
38/41
ProteinData"SP1", "MoleculePlot"
Import a PDB file.
Import"ExampleData1PPT.pdb"Import a PDB file by setting various options.
Import"ExampleData1PPT.pdb", "PDB", Background GrayLevel0.15,ImageSize Medium, "Rendering" "Wireframe"
Get the title of this PDB file.
Import"ExampleData1PPT.pdb", "PDB", "Title"XRAY ANALYSIS 1.4ANGSTROMS RESOLUTION OF
AVIAN PANCREATIC POLYPEPTIDE. SMALL GLOBULARPROTEIN HORMONE
Get the name of the organism referenced in this file.
Import"ExampleData1PPT.pdb","PDB", "Organism", "DepositionDate"
MOL_ID 1, ORGANISM_SCIENTIFIC MELEAGRIS GALLOPAVO, 1981, 1, 16, 0, 0, 0.
Import the residue sequence.
Import"ExampleData1PPT.pdb", "Residues" Gly Pro Ser Gln Pro Thr Tyr Pro Gly Asp Asp Ala Pro Val Glu Asp Leu Ile Arg Phe Tyr Asp Asn Leu Gln Gl
Import a 3D molecule model as a ball-and-stick model.
Import"ExampleDataaspirin.mol"
Show the bonds of the same molecule using spacefilling rendering.
Import"ExampleDataaspirin.mol", "Rendering" "Spacefilling"
38 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
39/41
Import a 3D molecule model as a wireframe model.
Import"ExampleDataaspirin.mol", "Rendering" "Wireframe"
When importing a molfile that contains a 2 D representation of a molecule, Mathematica automatically renders it as a
chemical structure diagram.
Import "ExampleDatafluoxetine.mol"
This gives the atom types and their 2D coordinates for the structure diagram.
Import"ExampleDatafluoxetine.mol","VertexTypes", "VertexCoordinates"
C C O C C C C
98.28, 75.86 98.28, 7.24 25.86, 117.59 170.69, 117.59 171.03, 48.97 26.21, 48.97 46.21, 75.86 242.4
This creates a molfile from the previous output.
molstr
ExportString , "MOL", "VertexTypes", "VertexCoordinates"
Data Visualization with Mathematica.03.nb 39
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
40/41
Created by Wolfram Mathematica 7.0 : www.wolfram.com
22 0 0 0 0 999 V2000
0.9828 0.7586 0.0000 C 0 0 0 0 0 0 0 0 0
0.9828 0.0724 0.0000 C 0 0 0 0 0 0 0 0 0
0.2586 1.1759 0.0000 O 0 0 0 0 0 0 0 0 0
1.7069 1.1759 0.0000 C 0 0 0 0 0 0 0 0 0
1.7103 0.4897 0.0000 C 0 0 0 0 0 0 0 0 0
0.2621 0.4897 0.0000 C 0 0 0 0 0 0 0 0 0
0.4621 0.7586 0.0000 C 0 0 0 0 0 0 0 0 0
2.4241 0.7621 0.0000 C 0 0 0 0 0 0 0 0 0
1.7103 1.3241 0.0000 C 0 0 0 0 0 0 0 0 0
0.2621 1.3241 0.0000 C 0 0 0 0 0 0 0 0 0
0.4621 0.0724 0.0000 C 0 0 0 0 0 0 0 0 0
1.1828 1.1759 0.0000 C 0 0 0 0 0 0 0 0 0
3.1483 1.1793 0.0000 N 0 0 0 0 0 0 0 0 0
0.9828 1.7414 0.0000 C 0 0 0 0 0 0 0 0 0
1.1793 0.4897 0.0000 C 0 0 0 0 0 0 0 0 0
1.9035 0.7586 0.0000 C 0 0 0 0 0 0 0 0 0
3.8690 0.7621 0.0000 C 0 0 0 0 0 0 0 0 0
1.9035 0.0759 0.0000 C 0 0 0 0 0 0 0 0 0
2.6241 0.4931 0.0000 C 0 0 0 0 0 0 0 0 0
3.4000 0.8690 0.0000 F 0 0 0 0 0 0 0 0 0
2.9724 0.0966 0.0000 F 0 0 0 0 0 0 0 0 0
2.2172 1.1621 0.0000 F 0 0 0 0 0 0 0 0 0
M END
40 Data Visualization with Mathematica.03.nb
-
8/9/2019 Data Visualization With Mathematica.no 3D Rasterization
41/41
ImportStringmolstr, "MOL", "VertexTypes"C, C, O, C, C, C, C, C, C, C, C, C, N, C, C, C, C, C, C, F, F, F
ImportStringmolstr, "MOL", "VertexCoordinates"98.28 75.86
98.28 7.24
25.86 117.59
170.69 117.59
171.03 48.97
26.21 48.97
46.21 75.86
242.41 76.21
171.03 132.41
26.21 132.41
46.21 7.24
118.28 117.59
314.83 117.93
98.28 174.14
117.93 48.97
190.35 75.86
386.9 76.21
190.35 7.59
262.41 49.31
340. 86.9
297.24 9.66
221.72 116.21
Initializations
sizeImageNotebook 200;
Data Visualization with Mathematica.03.nb 41