Data Visualization With Mathematica.no 3D Rasterization | 3 D Computer Graphics | Metallic Elements

Data Visualization

with
Mathematica
Philadelphia Math + Science Coalition
www.philaedfund.org/programs/advancing-education/philadelphia-math-science-
coalition
United Way Building
1709 Benjamin Franklin Parkway, Suite 700
Philadelphia, PA 19103
March 8, 2010
Edward Bujak
Edward_Bujak@hotmail.com
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.
<Name>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 Mathematica the data can be anything, not just numbers.
Mathematica
Mathematica files 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 Mathematica Player - 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.com
4. Can save almost anything (including cell, selections) as static RTF, PDF, HTML, TeX, TXT, PS, XML, package, GIF, JPG,
PNG, TIFF, BMP, WMF, L
A
T
E
X, MathML
5. Quiz generator.
Mathematica Syntax
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
Mathematica functions are mixed-case and start upper-case.
Do-Loop Construct
2 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
?Table
Ta ble [expr, ¦i
max
¦] ge ne ra t e s a lis t of i
max
copie s of expr.
Ta ble [expr, ¦i, i
max
¦] ge ne ra t e s a lis t of t he va lue s of expr whe n i runs from 1 t o i
max
.
Ta ble [expr, ¦i, i
min
, i
max
¦] s t a rt s wit h i i
min
.
Ta ble [expr, ¦i, i
min
, i
max
, di¦] us e s s t e ps di.
Ta ble [expr, ¦i, ¦i
1
, i
2
, …¦¦] us e s t he s ucce s s ive va lue s i
1
, i
2
, ….
Ta ble [expr, ¦i, i
min
, i
max
¦, ¦ j, j
min
, j
max
¦, …] give s a ne s t e d lis t . The lis t a s s ocia t e d wit h i is out e rmos t .
Table [2 x + 1, {x, 1, 6}]
¦3, 5, 7, 9, 11, 13¦
Table ]]x, 2 x, 2 x + 5, 2 x
4
|, {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.
Mathematica Visualization 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;
Plot[Sin[x], {x, 0, 2 r}, ImageSize - sizeImageNotebook]
1 2 3 4 5 6
1.0
0.5
0.5
1.0
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 3
Plot3D]Sin]x + y
2
|, {x, -3, 3},
{y, -2, 2}, ImageSize - sizeImageNotebook|
2
0
2
2
1
0
1
2
1.0
0.5
0.0
0.5
1.0
ContourPlot]Sin]x + y
2
|, {x, -3, 3},
{y, -2, 2}, ImageSize - sizeImageNotebook|
3 2 1 0 1 2 3
2
1
0
1
2
DiscretePlot[Prime[k], {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 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
data1 = ListPlot[Tooltip[{3, 4, 5}],
PlotStyle - {PointSize[0.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 = ListLinePlot[{3, 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:
Show[data1, data2]
0.5 1.0 1.5 2.0 2.5 3.0
3.5
4.0
4.5
5.0
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 5
ListLinePlot[Accumulate[RandomReal[{-1, 1}, 250]],
ColorFunction - "Rainbow", Filling - Axis,
ImageSize - sizeImageNotebook]
50 100 150 200 250
5
10
15
starData = Table[{Cos[k 2 Pi/7], Sin[k 2 Pi/7]}, {k, 0, 21, 3}]
1 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
N[starData]
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.
ListLinePlot[Tooltip[starData], Frame - True,
Axes - False, ImageSize - sizeImageNotebook]
0.5 0.0 0.5 1.0
1.0
0.5
0.0
0.5
1.0
6 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
ListPlot3D[{{0, 0, 1}, {1, 0, 0}, {0, 1, 0}},
Mesh - All, ImageSize - sizeImageNotebook]
0.0
0.5
1.0
0.0
0.5
1.0
0.0
0.5
1.0
dataSteps = Table[Sin[j^2 + i], {i, 0, Pi, Pi/5}, {j, 0, Pi, Pi/5}]
0 sin|
Π
2
25
| sin|
4 Π
2
25
| sin|
9 Π
2
25
| sin|
16 Π
2
25
| sin|Π
2
]
5
8

5
8
sin|
Π
5

Π
2
25
| sin|
Π
5

4 Π
2
25
| sin|
Π
5

9 Π
2
25
| sin|
Π
5

16 Π
2
25
| sin|
Π
5
Π
2
]
5
8

5
8
cos|
Π
10

Π
2
25
| cos|
Π
10

4 Π
2
25
| cos|
Π
10

9 Π
2
25
| cos|
Π
10

16 Π
2
25
| cos|
Π
10
Π
2
]
5
8

5
8
cos|
Π
10

Π
2
25
| cos|
Π
10

4 Π
2
25
| cos|
Π
10

9 Π
2
25
| cos|
Π
10

16 Π
2
25
| cos|
Π
10
Π
2
]
5
8

5
8
sin|
Π
5

Π
2
25
| sin|
Π
5

4 Π
2
25
| sin|
Π
5

9 Π
2
25
| sin|
Π
5

16 Π
2
25
| sin|
Π
5
Π
2
]
0 sin|
Π
2
25
| sin|
4 Π
2
25
| sin|
9 Π
2
25
| sin|
16 Π
2
25
| sin|Π
2
]
ListPlot3D[dataSteps, Mesh - None, InterpolationOrder - 0,
ColorFunction - "SouthwestColors", ImageSize - sizeImageNotebook]
2
4
6
2
4
6
1.0
0.5
0.0
0.5
1.0
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 7
ParametricPlot[{Sin[2 u], Sin[3 u]},
{u, 0, 2 Pi}, ImageSize - sizeImageNotebook]
1.0 0.5 0.5 1.0
1.0
0.5
0.5
1.0
ParametricPlot[r^2 { Sqrt[t] Cos[t], Sin[t]},
{t, 0, 3 Pi/2}, {r, 1, 2}, ImageSize - sizeImageNotebook]
6 4 2 0 2
4
2
0
2
4
8 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
ParametricPlot3D]
¦t ×
Cos[t]
10
, t ×
Sin[t]
10
,
t
10
¦,
{t, -6 r, 6 r},
ImageSize - sizeImageNotebook,
PlotStyle - {Thick, Red}
|
1
0
1
1
0
1
1
0
1
ParametricPlot3D[{1.16^v Cos[v] (1 + Cos[u]),
-1.16^v Sin[v] (1 + Cos[u]), -2 1.16^v (1 + Sin[u])},
{u, 0, 2 Pi}, {v, -15, 6}, Mesh - None, PlotStyle - Opacity[0.6],
PlotRange - All, PlotPoints - 25, ImageSize - sizeImageNotebook]
PolarPlot[Sin[5 t], {t, 0, r}, ImageSize - sizeImageNotebook]
0.5 0.5
0.5
0.5
1.0
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 9
ReliefPlot[Table[i + Sin[i^2 + j^2], {i, -4, 4, .03}, {j, -4, 4, .03}],
ColorFunction - "SunsetColors", ImageSize - sizeImageNotebook]
GraphPlot[Table[i - Mod[i^2, 102], {i, 0, 102}]]
A 100-node random graph with 1% of possible edges filled in:
10 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
GraphPlot[RandomChoice[{0.01, 0.99} - {1, 0}, {100, 100}]]
Layered graphs.
LayeredGraphPlot[{1 - 2, 1 - 3, 2 - 3, 1 - 4, 2 - 4, 1 - 5},
VertexLabeling - True, ImageSize - sizeImageNotebook]
1
2
3 4
5
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 11
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]
John lion
tiger deer
mosquito frog
cow
snake vulture
And many more:
ListPlot, DateListPlot, ListLogPlot,
RegionPlot, RegionPlot3D, DensityPlot, Lis t De ns it yPlot , ContourPlot, ArrayPlot, RegionPlot, StreamPlot, VectorPlot, StreamDensi-
tyPlot, VectordensityPlot,
St r e a mPlot Ve ct or Plot St r e a mDe ns it yPlot Ve ct or De ns it yPlot
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 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
$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"] import s da t a from a file , re t urning a comple t e Mathematica ve rs ion of it .
Import [" file", elements] import s t he s pe cifie d e le me nt s from a file .
Import ["ht t p: llurl", …] a nd Import ["ft p: llurl", …] import s from a ny a cce s s ible URL.
?Fit
Fit [data, funs, vars] finds a le a s t -s qua re s fit t o
a lis t of da t a a s a line a r combina t ion of t he funct ions funs of va ria ble s vars.
?FindFit
FindFit [data, expr, pars, vars] finds nume rica l va lue s of t he pa ra me t e rs pars t ha t ma ke expr give a
be s t fit t o data a s a funct ion of vars. The da t a ca n ha ve t he form ¦¦x
1
, y
1
, …, f
1
¦, ¦x
2
, y
2
, …, f
2
¦, …¦,
whe re t he numbe r of coordina t e s x, y, … is e qua l t o t he numbe r of va ria ble s in t he lis t vars. The
da t a ca n a ls o be of t he form ¦ f
1
, f
2
, …¦, wit h a s ingle coordina t e a s s ume d t o t a ke va lue s 1, 2, ….
FindFit [data, ¦expr, cons¦, pars, vars] finds a be s t fit s ubje ct t o t he pa ra me t e r cons t ra int s cons.
$DataDirectory = ToFileName[{NotebookDirectory[], "Data"}];
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 13
$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 =
ListPlot[Tooltip[dataLinear], PlotStyle - {PointSize[0.02], Green}]
2 4 6 8 10
30
40
50
Fit the data to the model a x b.
14 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
Clear [a, b];
fitLinear = FindFit[dataLinear, a x + b, {a, b}, x]
¦a 4.61415, b 8.924¦
Display the fit function together with the data.
Show[dataPlotLinear,
Plot[a 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 = ListPlot[dataNoisy]
1 2 3 4 5 6
1.0
0.5
0.5
1.0
Fit the data to the model Αsin(x ΒΓ sin(∆ x)).
fit = FindFit[dataNoisy, o + Sin[8 x + v Sin[5 x]], {o, 8, v, 5}, x]
¦Α 0.00718779, Β 1.00277, Γ 1.41681, ∆ 0.999737¦
Display the fit function together with the data.
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 15
Display the fit function together with the data.
Show[dataNoisyPlot,
Plot[o + Sin[8 x + v Sin[5 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
1.21987 0.150349
16 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
1.21987 0.150349
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.0066815
1.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.46948
1.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
2.29831 0.571845
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 17
2.29831 0.571845
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.0613637
2.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.58387
2.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 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
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.91916
3.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
3.59952 0.585253
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 19
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 =
ListPlot]dataPulsar, AspectRatio -
1
2
, 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,
o Sin[e t] + 8 Cos[e t] + v Sin[o t] + 5 Cos[o t] + e,
{{o, 1}, {8, 1}, {v, 1}, {5, 0}, {e, 23.31}, {o, 34.64}, {e, 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 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
Show[Plot[o Sin[e t] + 8 Cos[e t] + v Sin[o t] + 5 Cos[o t] + e /. 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, »
Prot e inDa t a[" prot"] give s t he re fe re nce a mino a cid s e que nce for t he prot e in prot.
Prot e inDa t a[" prot", " property"] give s t he va lue of t he s pe cifie d prope rt y for t he prot e in prot.
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 21
What Kind of Data and Meta-Data within Collection?
?ElementData
Ele me nt Da t a["name", " property"] give s t he va lue of t he s pe cifie d prope rt y for t he che mica l e le me nt "name".
Ele me nt Da t a[n, " property"] give s t he s pe cifie d prope rt y for t he n
t h
che mica l e le me nt .
List the ElementData[] collections:
ElementData[]
¦Hydrogen, 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¦
ElementData[1]
Hydrogen
Length[ElementData[]]
118
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 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
ElementData["Hydrogen", "MeltingPoint"]
259.14
ElementData[1, "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
Lis t Line Plot [¦y
1
, y
2
, …¦] plot s a line t hrough a lis t of va lue s, a s s ume d t o corre s pond t o x coordina t e s 1, 2, ….
Lis t Line Plot [¦¦x
1
, y
1
¦, ¦x
2
, y
2
¦, …¦] plot s a line t hrough s pe cific x a nd y pos it ions.
Lis t Line Plot [¦list
1
, list
2
, …¦] plot s s e ve ra l line s.
Table[ElementData[z, "MeltingPoint"], {z, 1, 118}]
|259.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.110
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.010
2
, 1050., 1750., 1572.,
1135., 644., 640., 1176., 1345., 1050., 900., 860., 1527., 827., 827., 1627., —, —, —, —, —, —, —, —, —, —, —, —, —, —, —|
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 23
ListLinePlot[Table[ElementData[z, "MeltingPoint"], {z, 1, 118}]]
20 40 60 80 100
500
1000
1500
2000
2500
3000
3500
?ListPlot
Lis t Plot [¦y
1
, y
2
, …¦] plot s point s corre s ponding t o a lis t of va lue s, a s s ume d t o corre s pond t o x coordina t e s 1, 2, ….
Lis t Plot [¦¦x
1
, y
1
¦, ¦x
2
, y
2
¦, …¦] plot s a lis t of point s wit h s pe cifie d x a nd y coordina t e s.
Lis t Plot [¦list
1
, list
2
, …¦] plot s s e ve ra l lis t s of point s.
ListPlot[Table[ElementData[z, "MeltingPoint"], {z, 1, 118}]]
20 40 60 80 100
500
1000
1500
2000
2500
3000
3500
Table[ElementData[z, "MeltingPoint"], {z, 118}]
|259.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.110
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.010
2
, 1050., 1750., 1572.,
1135., 644., 640., 1176., 1345., 1050., 900., 860., 1527., 827., 827., 1627., —, —, —, —, —, —, —, —, —, —, —, —, —, —, —|
dataMeltingPointElement =
Table[{ElementData[z, "MeltingPoint"], ElementData[z]}, {z, 118}]
24 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
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
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 25
157.36 Krypton
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. Lanthanum
798. Cerium
931. Praseodymium
1021. Neodymium
1.1 10
3
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 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
271.3 Bismuth
254. Polonium
302. Astatine
71. Radon
— Francium
7.0 10
2
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
Dime ns ions[expr] give s a lis t of t he dime ns ions of expr.
Dime ns ions[expr, n] give s a lis t of t he dime ns ions of expr down t o le ve l n.
Dimensions[dataMeltingPointElement]
¦118, 2¦
Length[dataMeltingPointElement]
118
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 27
dataMeltingPointElement[[1]]
¦259.14, Hydrogen¦
dataMeltingPointElement[[1]][[2]]
Hydrogen
ListLinePlot[Table[ElementData[z, "MeltingPoint"], {z, 1, 118}]]
20 40 60 80 100
500
1000
1500
2000
2500
3000
3500
28 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
ListLinePlot]
Tooltip[Table[ElementData[z, "MeltingPoint"], {z, 1, 118}]],
PlotLabel - "Melting Point vs Atomic Number",
AxesLabel - ]"Atomic\nNumber", "Melting\nPoint [°C]"|,
LabelStyle - Directive[Blue, Bold], GridLines - Automatic|
20 40 60 80
500
1000
1500
2000
2500
3000
3500
Melting
Point °C
Melting Point vs Atomic Number
dataMpBp = Table[{ElementData[z, "MeltingPoint"],
ElementData[z, "BoilingPoint"]}, {z, 1, 118}];
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 29
ListLinePlot[dataMpBp]
500 1000 1500 2000 2500 3000 3500
1000
2000
3000
4000
5000
ListPlot[dataMpBp]
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
Toolt ip[expr, label] dis pla ys label a s a t oolt ip while t he mous e point e r is in t he a re a whe re expr is dis pla ye d.
30 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
ListPlot[Tooltip[dataMpBp]]
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 = Table[{ElementData[z, "MeltingPoint"],
ElementData[z, "BoilingPoint"]}, {z, 1, 118}]
259.14 252.87
— 268.93
180.54 1342.
1287. 2470.
2075. 4000.
3550. 4027.
210.1 195.79
218.3 182.9
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 31
218.3 182.9
219.6 188.12
248.59 246.08
97.72 883.
650. 1090.
660.32 2519.
1414. 2.9 10
3
44.2 280.5
115.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
111.8 108.
32 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
111.8 108.
28.44 671.
727. 1870.
920. 3464.
798. 3360.
931. 3290.
1021. 3.1 10
3
1.1 10
3
3.010
3
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 10
2
1737.
1050. 3200.
1750. 4820.
1572. 4000.
1135. 3927.
644. 4.0 10
3
640. 3230.
1176. 2011.
1345. 3110.
1050. —
900. —
860. —
1527.
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 33
1527. —
827. —
827. —
1627. —
— —
— —
— —
— —
— —
— —
— —
— —
— —
— —
— —
— —
— —
— —
— —
Creating a Dynamic Interactive Manipulative to Huge Data Set
Manipulate[
plotType[Table[
{ElementData[z, prop1], ElementData[z, prop2]}, {z, 1, 118}]],
{plotType, {ListPlot, ListLinePlot,
ListLogPlot, ListLogLinearPlot}},
{prop1, ElementData["Properties"]},
{prop2, ElementData["Properties"]}
]
34 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
plot Type
Lis t Plot Lis t Line Plot Lis t LogPlot Lis t LogLine a rPlot
prop1 At omicNumbe r
prop2 At omicRa dius
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.
DateListPlot[
Tooltip[FinancialData["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.
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 35
DateListPlot[Tooltip[
{FinancialData["GE", "2006"], FinancialData["AKAM", "2006"],
FinancialData["MSFT", "2006"]}], Joined - True]
2006 2007 2008 2009 2010
10
20
30
40
50
60
AstronomicalData["Earth", "Image"]
Tooltip[AstronomicalData[¤, "Image"],
AstronomicalData[¤, "Name"]] & /® AstronomicalData["Planet"]
Make a graphic of solar system orbit paths with tooltips displaying images of each planet.
36 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
Graphics3D[{LightGray, Tooltip[AstronomicalData[¤, "OrbitPath"],
AstronomicalData[¤, "Image"]] & /®
AstronomicalData["Planet"]}, Background - Black]
Varying distance of planets from Earth in 2009:
AstronomicalData["Earth", "Distance", "Units"]
Meters
DateListPlot[
Tooltip[Table[{DateList[{2009, 1, i}], AstronomicalData[¤,
{"Distance", DateList[{2009, 1, i}]}]}, {i, 1, 365.25, 10}],
¤] & /® {"Mercury", "Venus", "Mars", "Jupiter", "Saturn"},
Joined - True, GridLines - Automatic]
Jan Apr Jul Oct Jan
0
5.010
11
1.010
12
1.510
12
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 37
ProteinData["SP1", "MoleculePlot"]
Import a PDB file.
Import["ExampleData/1PPT.pdb"]
Import a PDB file by setting various options.
Import["ExampleData/1PPT.pdb", "PDB", Background - GrayLevel[0.15],
ImageSize - Medium, "Rendering" - "Wireframe"]
Get the title of this PDB file.
Import["ExampleData/1PPT.pdb", {"PDB", "Title"}]
XRAY ANALYSIS(1.4ANGSTROMS RESOLUTION) OF
AVIANPANCREATIC POLYPEPTIDE. SMALL GLOBULARPROTEIN HORMONE
Get the name of the organism referenced in this file.
Import["ExampleData/1PPT.pdb",
{"PDB", {"Organism", "DepositionDate"}}]
¦¦MOL_ID 1, ORGANISM_SCIENTIFIC MELEAGRIS GALLOPAVO¦, ¦1981, 1, 16, 0, 0, 0.¦¦
Import the residue sequence.
Import["ExampleData/1PPT.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 Gln )
Import a 3D molecule model as a ball-and-stick model.
Import["ExampleData/aspirin.mol"]
Show the bonds of the same molecule using spacefilling rendering.
Import["ExampleData/aspirin.mol", "Rendering" - "Spacefilling"]
Import a 3D molecule model as a wireframe model.
38 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
Import a 3D molecule model as a wireframe model.
Import["ExampleData/aspirin.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[ "ExampleData/fluoxetine.mol"]
This gives the atom types and their 2D coordinates for the structure diagram.
Import["ExampleData/fluoxetine.mol",
{{"VertexTypes", "VertexCoordinates"}}]
C C O C 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.41
This creates a molfile from the previous output.
molstr =
ExportString[ «, {"MOL", {"VertexTypes", "VertexCoordinates"}}]
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 39
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 Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb
ImportString[molstr, {"MOL", "VertexTypes"}]
¦C, C, O, C, C, C, C, C, C, C, C, C, N, C, C, C, C, C, C, F, F, F¦
ImportString[molstr, {"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;
Dat a Vis ualiz at ion wit h Mat he m at ica. 03. nb 41

Sign up to vote on this title
UsefulNot useful