When I rotate my 3D plot to the desired viewpoint my X axis runs from 1 at the left to 0 at the right. How can I mirror my plot so that 0 will be at the left and 1 at the right?

Extra credit: how can I get the ViewPoint vector after manual rotation?

  • 2
    $\begingroup$ You can get the answer to your extra credit question here. $\endgroup$ – VLC Aug 11 '12 at 12:28

To answer the last part of question, this can be done by setting something like ViewPoint -> Dynamic[vp] in the plot definition. Then the value of vp will be dynamically updated to the current view point when you rotate the plot. Try for example

Plot3D[x^4 y, {x, 0, 1}, {y, 0, Pi}, PlotRange -> All, ViewPoint -> Dynamic[vp]]

Note that vp must be defined as a triple of numbers.

As for the first part of your question, I don't know how you're creating your plot, but if you're using Plot3D you could just swap the second and third argument. For example

vp = {1, 1, 1};
Plot3D[x^4 y Sin[5 y], {x, 0, 1}, {y, 0, Pi}, PlotRange -> All, 
 ViewPoint -> Dynamic[vp]]
Plot3D[x^4 y Sin[5 y], {y, 0, Pi}, {x, 0, 1}, PlotRange -> All, 
 ViewPoint -> Dynamic[vp[[{2, 1, 3}]]]]

Mathematica graphics Mathematica graphics

Note that this will effectively swap the x- and y-axis, thus changing the coordinate system from being right-handed to left-handed.

  • $\begingroup$ I may be misunderstanding but I don't think your answer to the first part of stevenvh's question actually answers the question. It seems to me that his problem is that his axis runs from higher value to lower value (e.g. 1 to 0) from left to right, rather than lower value to higher value (e.g. 0 to 1). Simply swapping the x and y axes won't do, because as we can see in your second plot, one of your horizontal axes still runs from higher value to lower value (about 3.2 to 0). How does one mirror that, so it runs from lower to higher value, like the other horizontal axis (0 to about 1)? $\endgroup$ – Ray Feb 11 '16 at 10:12

As an alternative to swapping x and y axes in Heike's answer, you can use a combination of settings for AxesEdge and ViewPoint:

 vp = {-2, 3, 2}; 
 Plot3D[Sin[x + y^2], {x, 0, 1}, {y, -1, 1}, 
 BoxRatios -> 1, AxesLabel -> {"X", "Y", "Z"}, Axes -> True, 
 AxesEdge -> {{1, 0}, {0, 0}, {0, 0}}, ViewPoint -> Dynamic[vp], 
 PlotLabel -> Dynamic[vp]]

enter image description here

  • $\begingroup$ Am I right that this only places the axes on the other side of the bounding box? It doesn't allow the Y = -1 to coincide with the X = 0, it seems. $\endgroup$ – stevenvh Aug 11 '12 at 13:55
  • $\begingroup$ @stevenvh, does changing AxesEdge->{{-1, 0}, {0, 0}, {0, 0}} give what you need? $\endgroup$ – kglr Aug 11 '12 at 14:03
  • $\begingroup$ No. I want the curve to be mirrored through the Y = 0 plane, so that Y = -1 and Y = 1 exchange places. $\endgroup$ – stevenvh Aug 11 '12 at 14:06
  • $\begingroup$ I see...perhaps some of form of ReflectionTransform.. $\endgroup$ – kglr Aug 11 '12 at 14:37
  • $\begingroup$ Sorry, still not what I want, I guess. I checked ReflectionTransform, and as I understand it it reflects the function, so that will be mirrored, but the axis won't. I need a mirrored view of the curve, but because the axis is reflected, not the function. Sorry. Thanks for your time, though. $\endgroup$ – stevenvh Aug 11 '12 at 14:50

There is a simpler way to see the ViewPoint vector (and many other plot attributes) after a manual rotation: just type //Options right after the Graphics object and evaluate.


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.