# Visualizing a imported XYZ-file and graphic object at same time

I want visualize a imported xyz-file and a graphic object at same time.

g = Import["H2O.xyz", "XYZ"];
Show[g, Graphics3D[{Opacity[0.5], Sphere[]}]]


But this shows only the xyz-file. Please, can someone help me?

This could be because the result of Show inherits graphics options from the first argument, this case the imported graphics. One of the important graphics options is PlotRange. Very likely this is explicitly set for the imported object, and the sphere might fall outside of these bounds (and thus may not visible).

If this is the case, explicitly set

Show[..., PlotRange -> Automatic]


to show everything.

Another possibility is that the sphere is so much smaller than the XYZ object that it is not visible. Also set Axes -> True in Show to get an idea about the size of the object.

Example:

Show[
Import["ExampleData/caffeine.xyz"],
Graphics3D[{Yellow, Opacity[0.5], Sphere[{0, 0, 0}, 200]}],
PlotRange -> All,
Axes -> True
]


I set Axes -> True to get a sense of the scale of the imported object. based on this, I set the sphere radius to 200. A sphere of radius 1 would be invisibly tiny.

• Thanks a lot for your help. I guess this is not the problem. I get "Show: Could not combine the graphics objects in Show" exception. – Mirco Sep 25 '18 at 13:35
• @Mirco In the question you said: "this shows only the xyz-file" and made no mention of any error message. Please update the question and describe the problem accurately. – Szabolcs Sep 25 '18 at 13:41
• @Mirco, may I suggest pasting the contents of your *.xyz file to Pastebin so other people can help you better? – J. M.'s technical difficulties Sep 25 '18 at 14:02
• Just to get an idea of how big the spheres used in these molecule plots can get: MinMax[GraphicsMoleculePlotDumpelementVanDerWaalRadii] yields {120, 300}. So, a radius 1 sphere would definitely be hard to spot. – J. M.'s technical difficulties Sep 25 '18 at 14:24
• @Szabolcs, Ah, my mistake. I had to know that Graphics3D has completely other scale the scale of xyz-file. Thank You. – Mirco Sep 25 '18 at 14:43