18
$\begingroup$

I have the following code to create animated GIFs:

ClearAll["`*"];
xmin = -3;
xmax = 4;
ymin = -10;
ymax = 3;
line1 = Line[{{xmin, ymin}, {xmin, ymax}}];
line2 = Line[{{xmax, ymin}, {xmax, ymax}}]; 
slides = 8; 
cmin = -10; 
cmax = 5/2; 
v = Table[Manipulate[
     Plot[{1/3 x^3 + x^2 + x - (2 x^2 + 4 x), c}, {x, xmin, xmax}, 
      PlotStyle -> {Blue, Red}, AspectRatio -> GoldenRatio, 
      PlotRange -> {{xmin, xmax}, {ymin, ymax}}, 
      Epilog -> {Directive[{Green, Green}], line1, line2}, 
      Background -> None], {{c, k/slides, "Constant:"}, cmin, cmax}],  
     {k, cmin*slides, cmax*slides}]; 
v = Join[v[[1 ;; Dimensions[v][[1]] - 1]], Reverse[v]];

When I use:

Export["testManip007.gif", v]

I obtained:

enter image description here

In order to get transparent background gif, I tried the following which worked for other cases:

Export["testManip007t.gif", v, "TransparentColor" -> White]

but the resulted is:

enter image description here

Additionally:

Export["testManip003t.gif", v, "DisplayDurations" -> 0.1, 
 "TransparentColor" -> White]

always causes error message and empty output.

How to solve the problems?

$\endgroup$
  • 2
    $\begingroup$ I tried setting Background explicitly to White but with no improvement to the exported gif. I then set both Background and "TransparentColor" to Yellow, which improved the appearance of the slider but not the plot itself. $\endgroup$ – bbgodfrey Nov 18 '14 at 6:35
  • 1
    $\begingroup$ Setting "Interlaced" option to True or False does not have an effect. $\endgroup$ – Alexey Popkov Nov 18 '14 at 6:59
  • $\begingroup$ You can't. Animations are realized through frames, i.e., the next frame appears through the former if you set "TransparentColor" -> White. My recommendation stay with white background. $\endgroup$ – user9660 Dec 4 '14 at 17:29
15
$\begingroup$

Note for Version 11.1: As commented by LCFactorization the option setting

"TransitionEffect" -> Background 

is no longer working (error message + nothing exported).

The solution is to use "TransitionEffect" -> "Background" instead, which doesn't produce the desired result in version 10.4 and earlier.


By default the frames of a GIF are stacked on top of each other. One can change this behavior using the Export option "TransitionEffect" -> Background:

Export["testManip007t.gif", v, "TransparentColor" -> White, "TransitionEffect" -> Background]

enter image description here

The default setting is "TransitionEffect" -> None.

$\endgroup$
  • $\begingroup$ Do you know what other TransitionEffect options are available? From Import[#, {"GIF", {"TransitionEffect"}}] & I have seen only None, False and Background. $\endgroup$ – rhermans Jun 1 '17 at 16:41
  • 1
    $\begingroup$ @rhermans I didn't come across any other option values either. I'm also not aware of something else the GIF file specifications would provide. It's a relative simple file format and the Mathematica exporter is rather primitive. $\endgroup$ – Karsten 7. Jun 1 '17 at 17:58
  • 2
    $\begingroup$ This option seems no longer work in the latest version 11.1? $\endgroup$ – LCFactorization Jul 14 '17 at 13:52
  • 3
    $\begingroup$ @LCFactorization You are correct, thanks for pointing that out. In version 11.1 you have to use "Background" instead of Background as the option value. $\endgroup$ – Karsten 7. Jul 14 '17 at 16:29
  • $\begingroup$ @Karsten7 It seems that this option no longer works in version 11.3, again. I've tried to find a solution for myself but I can't. Maybe you could use your skills again to solve this problem? Thank you very much in advance. $\endgroup$ – RoberRM May 17 '18 at 22:51

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.