4
$\begingroup$

I meet a very confusing problem in the new version 11.0, don't know if it is a bug or my option is not sufficient. Below is an simple example:

plot = ContourPlot3D[  x*y^2 + z == 0, {x, -1, 1}, {y, -1, 1}, {z, -1, 1.2},  LabelStyle -> Directive[FontSize -> 15, FontFamily -> "Times"], PerformanceGoal -> "Quality", PlotPoints -> 50,   ColorFunction -> Orange, Boxed -> True, AxesLabel -> {x, y, z},   Ticks -> {{-1, 0, 1}, {-1, 0, 1}, {-1, 0, 1}}, AspectRatio -> 1,   Mesh -> 14, ImageSize -> 16 cm,   ViewPoint -> {-0.133957, 0.38332, 2.0615} ]

Even though I have specified the view point, if I drag the output figure and run this code again, it will give me a different view point from result in the first run. I remember this does not happen in previous versions. I wonder if there is any other options that can help make it constant?

A related question is to control the viewpoint of "Show" command. When I specify the viewpoint of the show command, e.g. in the code

Show[plot,Viewpoint->{1,2,1}]

it gives me a viewpoint different from the result if I give this viewpoint directly to "plot". So what is the problem? Thanks.

Update I:

thanks for all your answers, the method by PreserveImageOptions -> False works for one figure, but seems adding viewVertical does not solve the problem. It's weird that the "viewVertical " method works in the first attempt I used, but didn't in the attempt I just conducted.

Now the remaining problem is how to get the view point etc in the Show command. What I need to do is to combine two objects by show command, then I manipulate this figure to find a good viewpoint to see both objects, then I want to find its viewpoint information and give them back to the first plot, so that I should be able to control the viewpoint of "plot". Below is an example using the Dynamic[] to monitor some of the view point information:

plot = ContourPlot3D[  x*y^2 + z == 0, {x, -1, 1}, {y, -1, 1}, {z, -1, 1.2},  LabelStyle -> Directive[FontSize -> 15, FontFamily -> "Times"], PerformanceGoal -> "Quality", PlotPoints -> 50,  ColorFunction -> Orange, Boxed -> True, AxesLabel -> {x, y, z},  Ticks -> {{-1, 0, 1}, {-1, 0, 1}, {-1, 0, 1}}, AspectRatio -> 1, Mesh -> 14, ImageSize -> Medium,  ViewPoint -> {1.60268, -1.95196, 2.25194}, ViewVertical -> {0.377222, -0.362082, 0.852409}, PreserveImageOptions -> False];

plot2 = Graphics3D[Cuboid[{0, 0, 0}, {0.2, 0.3, 0.5}]]

 vp = Options[Graphics3D, ViewPoint][[1, 2]];
vv = Options[Graphics3D, ViewPoint][[1, 2]];  

s1 = Show[plot, plot2, ViewPoint -> Dynamic[vp],   ViewVertical -> Dynamic[vv]]
Dynamic[vp]
Dynamic[vv]
s2 = Show[plot, ViewPoint -> {2.2805, -1.90789, 1.61533}, ViewVertical -> {0.673949, -0.563834, 0.477373}, PreserveImageOptions -> False]

In this example, I manipulate s1 and monitor their view point and view vertical and give it back to s2, but they don't produce the same view. So seems that this again shows that the viewpoint and viewvertical is not sufficient to determine the same view.

So how can I extract all the information from the show command so that I can use it to control the view of "plot"? Thanks a lot!

$\endgroup$
3
  • 1
    $\begingroup$ Do you get what you want if you use the option PreserveImageOptions -> False? See PreserveImageOptions $\endgroup$
    – kglr
    Commented Mar 7, 2017 at 21:04
  • $\begingroup$ Add the option ViewVertical->{0.,0.,1.} $\endgroup$
    – andre314
    Commented Mar 7, 2017 at 21:05
  • $\begingroup$ The second part of your question is answered here $\endgroup$
    – andre314
    Commented Mar 10, 2017 at 13:47

1 Answer 1

3
$\begingroup$

You can use option PreserveImageOptions -> False:

From PreserveImageOptions >> Details:

Mathematica graphics
Mathematica graphics
Mathematica graphics
Mathematica graphics

ContourPlot3D[x*y^2 + z == 0, {x, -1, 1}, {y, -1, 1}, {z, -1, 1.2}, 
 LabelStyle -> Directive[FontSize -> 15, FontFamily -> "Times"],
 PerformanceGoal -> "Quality", PlotPoints -> 50, 
 ColorFunction -> Orange, Boxed -> True,
 AxesLabel -> {x, y, z}, Ticks -> {{-1, 0, 1}, {-1, 0, 1}, {-1, 0, 1}},
 AspectRatio -> 1, Mesh -> 14, ImageSize -> 400, 
 ViewPoint -> {-0.133957, 0.38332, 2.0615},
 PreserveImageOptions -> False]

enter image description here

Alternatively, you can explicitly set the options ViewPoint,ViewCenter, ViewVertical, ViewAngle, ImageSize and ImageMargins options.

$\endgroup$

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.