« View all new features in
Mathematica
9
◄
previous
|
next
►
New in
Mathematica
9
›
Legends
Legend Elements in a Molecule
Add a legend to a 3D model of the molecules in caffeine.
In[1]:=
X
caffeine = Show[ChemicalData["Caffeine", "MoleculePlot"], PlotLabel -> Style["Caffeine 3D Molecular Plot", 20], LabelStyle -> {GrayLevel[0.3], Bold}]
Out[237]=
Look up the elements in caffeine and create a legend that matches them with their iconic colors.
In[2]:=
X
elements = ChemicalData["Caffeine", "ElementTypes"]; elementLegend = SwatchLegend[ElementData[#, "IconColor"] & /@ elements, elements, LegendMarkerSize -> 20, LabelStyle -> {Bold, GrayLevel[0.3], 18}]
Out[2]=
Add the element legend to the caffeine molecular plot.
In[3]:=
X
Legended[caffeine, elementLegend]
Out[241]=