I would like to scale one of the axes in a Parametric3DPlot. I tried adapting the recipe given in this answer to this case, but, as shown below, this attempt failed:

 Table[ParametricPlot3D[{Cos[u], Sin[u] + Cos[v], Sin[v]}, {u, 0,  2 π}, {v, -π, π}, 
   ScalingFunctions -> {Identity, scale, Identity}, 
   BoxRatios -> Automatic, 
   PlotRange -> All], {scale, {{2 # &, #/2 &},  Identity, {#/2 &, 2 # &}}}]]

Mathematica graphics

Specifically, the aspect ratios are as they should be, but the numbers along the scaled y-axis are wrong. They should be the same for all three plots.

In fact, the results above are essentially the same as one would get with this:

 Table[ParametricPlot3D[{Cos[u], scale (Sin[u] + Cos[v]), Sin[v]}, 
                       {u, 0, 2 π}, {v, -π, π}, 
                       BoxRatios -> Automatic,  PlotRange -> All], 
       {scale, {2, 1, 1/2}}]]

...and this is decidedly not what I'm trying to do. I just want to stretch or shrink the y-axis by a specified scaling factor, but retaining all the tick marks along the axis, and keeping the numbers along the axis unchanged (only their relative spacing should change).

(Granted, there's no reason to expect ScalingFunctions to work here, since the documentation does not cover the way I'm using it.)

Is there some other way to scale the y-axis?

  • $\begingroup$ Try explicitly setting the PlotRange. $\endgroup$ – N.J.Evans Oct 6 '15 at 20:59
  • 1
    $\begingroup$ Or perhaps you want AspectRatio $\endgroup$ – Dr. belisarius Oct 6 '15 at 21:01
  • $\begingroup$ I think you mean BoxRatios. $\endgroup$ – N.J.Evans Oct 6 '15 at 21:07

You can use FunctionRange to workout the ratios for BoxRatios.

funcs = {Cos[u], Sin[u] + Cos[v], Sin[v]};

range = FunctionRange[funcs, {u, v}, {x, y, z}];

br = (Cases[
        range, _[_, #, _]] /. _[lower_, #, upper_] -> (upper - lower)) & /@ {x, y, z} // Flatten;

ParametricPlot3D[funcs, {u, 0,2 \[Pi]}, {v, -\[Pi], \[Pi]}, BoxRatios -> br, ImageSize -> 200]

enter image description here

| improve this answer | |

I think this is what you're looking for:

  ParametricPlot3D[{Cos[u], Sin[u] + Cos[v], Sin[v]}, {u, 0, 
    2 \[Pi]}, {v, -\[Pi], \[Pi]}, BoxRatios -> br, ImageSize -> 200]
  , {br, {{1, 4, 1}, {1, 2, 1}, {1, 1, 1}}}

enter image description here

Where BoxRatios gives the relative scaling of {x,y,z} of the bounding box. i.e. the axes.

| improve this answer | |
  • $\begingroup$ Thanks, but no, this is not what I am looking for. The desired solution should be invariant with respect to changes in the proportions of the underlying 3D graphics. In contrast, the solution you propose requires inspecting the proportions of the underlying base graphics, and using this information to compute the required BoxRatios to produce the desired scaling. IOW, the code above would fail to properly scale the y-axis if, for example, the function being plotted were... $\endgroup$ – kjo Oct 6 '15 at 22:03
  • $\begingroup$ ... parametrized with {Sin[u] + Cos[v], Cos[u], Sin[v]}, because with this new function the proportions of the underlying 3D graphics are different. $\endgroup$ – kjo Oct 6 '15 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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