开发者

Resize a list of images in Mathematica for use with ListAnimate

Suppose we have a list of images, like the following:

imageList = Table[Plot[Sin[k*x], {x, 0, 2 Pi}], {k, 1, 4, .05}];

We can animate those images like so:

ListAnimate[imageList]

But now suppose we want the animation bigger. We co开发者_开发知识库uld stick an ImageSize option into the Plot command used to generate the images, but suppose we're not allowed to tamper with imageList.

We could manually resize each frame in the list animation. That works, but how can we accomplish that less tediously?


The key option is ImageSize. You can use it with the various plot commands, as well as with Show and Export. ImageSize can be given as {<width>,<height>} (where either can be Automatic to have the other set according to AspectRatio) or as <width> which is short for {<width>, Automatic}. In short, you can do stuff like

gfx = Plot[x^2, {x, 0, 1}, ImageSize -> 200]
Show[gfx, AspectRatio -> 1, ImageSize -> {Automatic, 100}]

If you really want control of the graphics layout, you need to start playing around with ImagePadding and PlotRangePadding as well, but be prepared for gray hair if you go in this direction!

Edit: For your particular case with the graphics already generated in imageList, it all comes together like so

ListAnimate[Show[#, ImageSize->800]& /@ imageList]


I'm a bit puzzled by your question.

    ListAnimate[Table[Plot[x^n, {x, -5, 5}, ImageSize -> {100 n, 75 n}], {n, 1, 5}]]

works fine for me, in as much as it draws the images with the specified sizes. It's a bit of a mess in this example, I grant you. The ListAnimate command also makes a panel with a frame big enough for the largest graphic in this case.

Post again if I've answered the wrong question for you, that's one of my specialities.


The following is one viable answer to the question as currently worded, with thanks to the initial answers by High Performance Mark and Janus:

ListAnimate[Show[#, ImageSize->800]& /@ imageList]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜