I've been trying to export a Plot3D into an X3D (JVX, VRML) file using the Mathematica's Export function. The problem is that when the PlotRange is large compared to the other two dimensions the output is essentially stretched into a thin line. Is there a way to maintain the original scaling?

Try the following:

Export["file.x3d", Plot3D[x^2+y^2,{x,-10,10},{y,-10,10}]];

The VerticalAxis option does not seem to help...



1 Answer 1


The "original scaling" of the displayed plot in Mathematica is determined by the BoxRatios setting for the plot, so it isn't intrinsic to the surface you're trying to export. When you export the plot, only the mesh is kept, with its actual 3D coordinates and without the scaling due to BoxRatios.

Therefore, if you want to export the surface in a "squished" form, you'll have to do the squishing yourself:

p = Plot3D[x^2+y^2,{x,-10,10},{y,-10,10}];
With[{zScale = .05},
  p /. Graphics3D[gr_, opts___] :> 
     GeometricTransformation[gr, ScalingTransform[{1, 1, zScale}]], 

I checked that this produces the desired "aspect ratio" by importing the file into Blender.

  • $\begingroup$ Alternatively, one can encase the X3D file inside <transform> tags, setting an inhomogeneous scale='1. 1. 0.05'. $\endgroup$ Commented May 22, 2015 at 0:42
  • $\begingroup$ @episanty Wouldn't that also squish the axis labels? $\endgroup$
    – Jens
    Commented May 22, 2015 at 1:09
  • $\begingroup$ I've not seen x3d export produce axes or labels to go on them (the output is verbose but easy to inspect as it is essentially xml), but maybe there's options that will do it cleanly (which I would like to see indeed). I doubt that VRML works too differently. $\endgroup$ Commented May 22, 2015 at 1:48
  • $\begingroup$ @episanty Good point - I think adding a transformation after the fact is certainly equally possible. $\endgroup$
    – Jens
    Commented May 22, 2015 at 3:58

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.