2
$\begingroup$

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?

$\endgroup$
0

1 Answer 1

1
$\begingroup$

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
]

Mathematica graphics

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.

$\endgroup$
5
  • $\begingroup$ 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. $\endgroup$
    – Mirco
    Sep 25, 2018 at 13:35
  • $\begingroup$ @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. $\endgroup$
    – Szabolcs
    Sep 25, 2018 at 13:41
  • 1
    $\begingroup$ @Mirco, may I suggest pasting the contents of your *.xyz file to Pastebin so other people can help you better? $\endgroup$ Sep 25, 2018 at 14:02
  • $\begingroup$ Just to get an idea of how big the spheres used in these molecule plots can get: MinMax[Graphics`MoleculePlotDump`elementVanDerWaalRadii] yields {120, 300}. So, a radius 1 sphere would definitely be hard to spot. $\endgroup$ Sep 25, 2018 at 14:24
  • $\begingroup$ @Szabolcs, Ah, my mistake. I had to know that Graphics3D has completely other scale the scale of xyz-file. Thank You. $\endgroup$
    – Mirco
    Sep 25, 2018 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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