Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Creating animated 3d graphic in Mathematica for export

652 views
Skip to first unread message

Coleman, Mark

unread,
Nov 6, 2008, 4:05:09 AM11/6/08
to
Greetings,

I'm attempting to create a simple animation of a 3D ListPlot. In the
animation I'd like to simply rotate the graphic continuously and
automatically (no user input), and then export this animation into a
common video format (MPEG or Quicktime). Does anyone have an example of
this?

Thanks,

Mark

Nikolaus Rath

unread,
Nov 7, 2008, 5:58:15 AM11/7/08
to

I usually export pictures and encode them with a separate encoder.
With mencoder, this works like this:


fps = 15;
length = 5;
Export["mathematica-plot-"
<> ToString[NumberForm[#, 3, NumberPadding -> {"0", "0"}] ]
<> ".jpg",
Plot[f[t/fps, x], {x, 0, 10}],
ImageResolution -> 100] & /@ Range[0, length fps];

Run["mencoder \"mf://mathematica-plot-*.jpg\" -mf fps=" <> ToString[fps=
] <>
" -o mathematica.avi -ovc lavc -lavcopts vcodec=mpeg4"];

This generates a movie of the time evolution of f[t,x] from t=0 to t==
5
with a framerate of 15 frames per second. You should be able to adapt
this for a 3D ListPlot easily.

HTH,

-Nikolaus

--
=C2=BBIt is not worth an intelligent man's time to be in the majority.
By definition, there are already enough people to do that.=C2=AB
-J.H. Hardy

PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C

Louis A. Talman

unread,
Nov 7, 2008, 5:58:36 AM11/7/08
to

On Nov 6, 2008, at 2:05 AM, Coleman, Mark wrote:

> I'm attempting to create a simple animation of a 3D ListPlot. In the
> animation I'd like to simply rotate the graphic continuously and
> automatically (no user input), and then export this animation into a
> common video format (MPEG or Quicktime). Does anyone have an
> example of
> this?

See <http://clem.mscd.edu/~talmanl/MathAnim.html>.

In past versions of Mathematica, I've found that the QT export
facility was unsatisfactory. I construct animations by writing
serially named .gifs or .pngs to a convenient directory and then
using either QuickTime itself, or, better, Thorsten Lemke's Graphic
Converter (Macintosh software) to paste those graphics files together
into a QuickTime movie.


--Lou Talman
Department of Mathematical and Computer Sciences
Metropolitan State College of Denver

<http://clem.mscd.edu/%7Etalmanl>

Alexei Boulbitch

unread,
Nov 7, 2008, 6:00:34 AM11/7/08
to
Hi, Mark,
I am copying here a code that I used for the same purposes with Plot3D.

Going to 3D ListPlot should be straightforward.


(* This is a z=z(x,y) function to show *)

z[x_, y_] :=
Exp[-(Sqrt[x^2 + y^2]/Power[4, (3)^-1]) +
Power[4, (3)^-1]*Sqrt[1/2*(Sqrt[x^2 + y^2] + x)]];

(*and its graph*)

pl1 = Plot3D[2*z[x, y], {x, -5, 5}, {y, -5, 5},
PlotStyle -> {Opacity[0.8]}, ColorFunction -> "Rainbow",
Mesh -> None, Boxed -> False, ImageSize -> 500];

(* here a graphics array is made. In this place one may play with the
rotation angle (here it is 4 degrees) and choose the axis of rotation in
the expression Rotate[pl1[[1]], 4*i*Degree, {0, 0, 1}] *)

Do[gr[i_] :=
Graphics3D[

Rotate[pl1[[1]], 4*i*Degree, {0, 0, 1}],
PlotRange -> {{-5, 5}, {-5, 5}, {0, 6}}, Boxed -> False ],
{i, 0, 1440, 1}
];

(* and a table entitled "v" out of it (of coarse may be also done in one
step), the parameter to play in this place is the number of steps, which
is 90=360/4 here *)

v = Table[gr[i], {i, 0, 90, 1}];

(*Here it is exported into an avi file. The parameter to play with is
the frame rate*)

Export[""Full_trajectory_to_the_file\v.avi", v, "FrameRate" -> 5]

Have fun :-) , Alexei


Greetings,

I'm attempting to create a simple animation of a 3D ListPlot. In the
animation I'd like to simply rotate the graphic continuously and
automatically (no user input), and then export this animation into a
common video format (MPEG or Quicktime). Does anyone have an example of
this?

Thanks,

Mark


--
Alexei Boulbitch, Dr., Habil.
Senior Scientist

IEE S.A.
ZAE Weiergewan
11, rue Edmond Reuter
L-5326 Contern
Luxembourg

Phone: +352 2454 2566
Fax: +352 2454 3566

Website: www.iee.lu

This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal from your system. Thank you for your co-operation.

herna...@gmail.com

unread,
Aug 31, 2012, 4:02:20 AM8/31/12
to
Alexei Thank you very much! It works really god, but how can I do to make the export plot bigger? I set ImageSize->600 or more but what I get is the same small plot but big file dimensions, do you understand what I mean?

Thank you!

Alexei Boulbitch

unread,
Sep 4, 2012, 5:49:06 AM9/4/12
to
iAlexei Thank you very much! It works really well, but how can I do to make the export plot bigger? I set ImageSize->600 or more but what I get is the same small plot but big file dimensions, do you understand what I mean?

Thank you!

You are welcome. I guess it is about the new document window with a graphics, which is open by demand upon pressing the button, is it?.

In this case you may indeed fix the ImageSize in the Plot function (or any graphics you will use instead), but it is important that simultaneously you specify the size of the opening window to be slightly larger than your plot in the horizontal direction and slightly smaller in the vertical one. Say, like this:

sz=550;
Button["Show Fig.1",CreateDocument[Column[{Row[{ExpressionCell[Plot[Sin[x],{x,0,3.14},ImageSize->sz],"Output"],}],TextCell[Style["Fig. 1. This is some explanation ",12],"Output"],Button[Style["Close the window",16,Blue],NotebookClose[]]}],WindowTitle->"Fig. 1, Short title",WindowSize->{sz+20,sz-20}]]

sz here is the size of the image. How much precisely larger and smaller to make the window, I do not know. I put WindowSize->{sz+20,sz-20} just as a first shot. Do it by trial and error.

Have fun, Alexei


Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone : +352-2454-2566
Office fax: +352-2454-3566
mobile phone: +49 151 52 40 66 44

e-mail: alexei.b...@iee.lu

Alexei Boulbitch

unread,
Sep 4, 2012, 5:51:55 AM9/4/12
to
0 new messages