Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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...


share|improve this question

1 Answer 1

up vote 7 down vote accepted

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.

share|improve this answer
Alternatively, one can encase the X3D file inside <transform> tags, setting an inhomogeneous scale='1. 1. 0.05'. –  episanty May 22 at 0:42
@episanty Wouldn't that also squish the axis labels? –  Jens May 22 at 1:09
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. –  episanty May 22 at 1:48
@episanty Good point - I think adding a transformation after the fact is certainly equally possible. –  Jens May 22 at 3:58

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.