4
$\begingroup$

I would like to create a stereogram from a 3d plot; I would like to export two images of a 3d plot at a slightly different angle, so that when each picture is presented to a different eye, one gets the feeling it is actually 3 dimensional.

I have tried to put two plots next to eachother, then turn one plot slightly by hand (mouse), but when I then export, it is as if I hadn't turned the plot at all!

example:

s1 = 
  Plot3D[PDF[MultinormalDistribution[{0, 0}, {{1, 1/2}, {1/2, 1}}], {x, y}],
    {x, -2.3, 2.3}, {y, -2.3, 2.3}]
Show[GraphicsArray[{s1, s1}]]

How can I specify at which angle the 3d plot is exported?

PS: Just to be clear: I don't want to rotate the function which is plotted, I want to rotate the plot, including the edges of the bounding box of the plot.

$\endgroup$
5
  • 1
    $\begingroup$ Have you checked ViewVector? $\endgroup$
    – Öskå
    May 21, 2014 at 12:36
  • 2
    $\begingroup$ Seems to work. Why isn't it in the documentation of Plot3D? $\endgroup$
    – Angelorf
    May 21, 2014 at 12:39
  • $\begingroup$ It is in Options@Plot3D at least.. :) $\endgroup$
    – Öskå
    May 21, 2014 at 12:39
  • $\begingroup$ I see. I didn't know the possibility to do Options@ yet. Thanks. $\endgroup$
    – Angelorf
    May 21, 2014 at 12:42
  • 1
    $\begingroup$ Some graphics options appear only in the documentation of Graphics3D. $\endgroup$
    – Michael E2
    May 21, 2014 at 14:18

1 Answer 1

7
$\begingroup$

Here is a small tool make it easier thanks to that answer:

With[{dplot = 
     Plot3D[PDF[MultinormalDistribution[{0, 0}, {{1, 1/2}, {1/2, 1}}], 
       {x, y}], {x, -2.3, 2.3}, {y, -2.3, 2.3}, ImageSize -> 350, 
       ViewVector -> Dynamic@vp]},
 DynamicModule[{vp, views, plot},
   Panel@Column[{dplot, 
     Button["Record View point", AppendTo[views, vp]], 
     Button["Export", {Export["~/test.pdf", GraphicsRow[plot /@ views]]; 
       extViews = views}]}, Center],

   Initialization :> (
     extViews = 0;
     views = {};
     plot = 
     Plot3D[PDF[MultinormalDistribution[{0, 0}, {{1, 1/2}, {1/2, 1}}], 
       {x, y}], {x, -2.3, 2.3}, {y, -2.3, 2.3}, ImageSize -> 350, 
       ViewVector -> #] &;
    vp = Options[Graphics3D, ViewPoint][[1, 2]];
    )]]

enter image description here

producing:

enter image description here

My problem here is that I have to write twice the Plot3D, one with Dynamic@vp one with #. If anyone can enlighten me.. :)

$\endgroup$
4
  • $\begingroup$ I suppose you could store the plot in a variable and then use Show to change ViewVector. But your code doesn't work for me because of problems with the syntax. $\endgroup$
    – C. E.
    May 21, 2014 at 14:29
  • $\begingroup$ @Pickett dangdang, thanks for telling me! $\endgroup$
    – Öskå
    May 21, 2014 at 14:34
  • $\begingroup$ It works for me (MMA 9). $\endgroup$
    – corey979
    Apr 10, 2015 at 17:13
  • $\begingroup$ @corey979 I'm glad it does, I did use v8 if I remember correctly :) $\endgroup$
    – Öskå
    Apr 10, 2015 at 18:10

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