Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

$\require{mhchem}$I would like to take the acetone $\cf{((CH3)2CO)}$ and chloroform $\cf{(HCCl_3)}$ molecules that Mathematica's chemical data provides, and plot them together. I want to show how chloroform can hydrogen bond to acetone. Right now I have them plotted on top of each other :/

Show[ChemicalData["Chloroform", "MoleculePlot"], 
 ChemicalData["Acetone", "MoleculePlot"]]

acetone and chloroform

share|improve this question
...I don't think Mathematica is the best software to use for this. Why not use a dedicated 3D chemical drawing program? – J. M. Apr 7 '13 at 19:31
If you examine the FullForm of the molecular plots, you may come up with a one-off solution. Some assembly may be required. – DavidC Apr 7 '13 at 20:11
Are there any free 3D chemical drawing programs? – olliepower Apr 7 '13 at 20:17
Somewhat related (for post-processing): Can a LatticeData image be displayed in a space filled fashion. – Jens Apr 7 '13 at 20:24
up vote 14 down vote accepted

A quick way of showing how the two structures can be positioned relative to each other in a single Graphics3D is as follows:

With[{rMax = 500},
   {First@ChemicalData["Acetone", "MoleculePlot"], 
     First@ChemicalData["Chloroform", "MoleculePlot"], 
      TranslationTransform[{displacementX, displacementY, 
       rotationAngle, {Cos[axisAzimuth] Sin[axisPolar], 
        Sin[axisAzimuth] Sin[axisPolar], Cos[axisPolar]}]]]},
   PlotRange -> {{-rMax, rMax}, {-rMax, rMax}, {-rMax, rMax}}
  {{displacementX, 0}, -rMax, rMax}, {{displacementY, 0}, -rMax, 
   rMax}, {{displacementZ, 0}, -rMax, rMax}, {rotationAngle, 0, 
   2 Pi},
  {axisPolar, 0, 2 Pi}, {axisAzimuth, 0, 2 Pi}


The Manipulate is just to let you do some manual re-positioning. You can eventually get better results by doing pre-calculated shifts and rotations based on the exact locations of the atoms. But I'm focusing here on the basic ingredients. For the display, this involves mainly the use of First to extract the contents of the Graphics3D of the molecule, then the translation and rotation using GeometricTransformation with a Composition of the former two operations.

The variable rMax sets the plot range and the maximum displacement of the chloroform molecule relative to the acetone.

share|improve this answer
+1 Very nice! Now this is the first step to do genetic manipulation completely inside Mma :D – Dr. belisarius Apr 7 '13 at 21:05
wow, excellent work. This is exactly what I was looking for. – olliepower Apr 7 '13 at 23:59

Here is a less impressive take on the question.

positionsA = 
   ChemicalData["Acetone", "AtomPositions"] /. {x_, y_, z_} -> {x + 400, y + 400, z + 400};
positionsC = ChemicalData["Chloroform", "AtomPositions"];
{atomsA, atomsC} = {ChemicalData["Acetone", "VertexTypes"], 
                     ChemicalData["Chloroform", "VertexTypes"]};
{colorsA, colorsC} = {Map[ColorData["Atoms", #] &, atomsA], 
                       Map[ColorData["Atoms", #] &, atomsC]};
{radiiA, radiiC} = {Map[ElementData[#, "VanDerWaalsRadius"] &, atomsA], 
                     Map[ElementData[#, "VanDerWaalsRadius"] &, atomsC]};
{molA, molC} = {Graphics3D[{Specularity[White, 40], 
                MapThread[{#1, Sphere[#2, #3]} &, {colorsA, positionsA, radiiA}]}], 
                 Graphics3D[{Specularity[White, 40], 
                MapThread[{#1, Sphere[#2, #3]} &, {colorsC, positionsC, radiiC}]}]};

Show[molA, molC, Lighting -> "Neutral"]

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.