diff --git a/src/sage/plot/animate.py b/src/sage/plot/animate.py index 9df404edcfd..79882221ca5 100644 --- a/src/sage/plot/animate.py +++ b/src/sage/plot/animate.py @@ -30,6 +30,7 @@ The sine function:: + sage: x = SR.var("x") sage: sines = [plot(c*sin(x), (-2*pi,2*pi), color=Color(c,0,0), ymin=-1, ymax=1) for c in sxrange(0,1,.2)] sage: a = animate(sines) sage: a # optional -- ImageMagick @@ -61,8 +62,7 @@ Animations of 3d objects:: - sage: var('s,t') - (s, t) + sage: s,t = SR.var("s,t") sage: def sphere_and_plane(x): ....: return sphere((0,0,0),1,color='red',opacity=.5)+parametric_plot3d([t,x,s],(s,-1,1),(t,-1,1),color='green',opacity=.7) sage: sp = animate([sphere_and_plane(x) for x in sxrange(-1,1,.3)]) @@ -72,7 +72,7 @@ Graphics3d Object sage: sp.show() # optional -- ImageMagick - sage: (x,y,z) = var('x,y,z') + sage: (x,y,z) = SR.var("x,y,z") sage: def frame(t): ....: return implicit_plot3d((x^2 + y^2 + z^2), (x, -2, 2), (y, -2, 2), (z, -2, 2), plot_points=60, contour=[1,3,5], region=lambda x,y,z: x<=t or y>=t or z<=t) sage: a = animate([frame(t) for t in srange(.01,1.5,.2)]) @@ -85,7 +85,7 @@ method :meth:`sage.plot.animate.Animation.make_image`. This is illustrated by the following example:: - sage: t = var('t') + sage: t = SR.var("t") sage: a = animate((sin(c*pi*t) for c in sxrange(1,2,.2))) sage: a.show() # optional -- ImageMagick @@ -133,7 +133,7 @@ def animate(frames, **kwds): EXAMPLES:: - sage: t = var('t') + sage: t = SR.var("t") sage: a = animate((cos(c*pi*t) for c in sxrange(1,2,.2))) sage: a.show() # optional -- ImageMagick @@ -161,6 +161,7 @@ class Animation(WithEqualityById, SageObject): EXAMPLES:: + sage: x = SR.var("x") sage: a = animate([sin(x + float(k)) for k in srange(0,2*pi,0.3)], ....: xmin=0, xmax=2*pi, figsize=[2,1]) sage: a # optional -- ImageMagick @@ -200,6 +201,7 @@ class Animation(WithEqualityById, SageObject): We check that :trac:`7981` is fixed:: + sage: x = SR.var("x") sage: a = animate([plot(sin(x + float(k)), (0, 2*pi), ymin=-5, ymax=5) ....: for k in srange(0,2*pi,0.3)]) sage: a.show() # optional -- ImageMagick @@ -207,6 +209,7 @@ class Animation(WithEqualityById, SageObject): Do not convert input iterator to a list, but ensure that the frame count is known after rendering the frames:: + sage: x = SR.var("x") sage: a = animate((plot(x^p, (x,0,2)) for p in sxrange(1,2,.1))) sage: str(a) 'Animation with unknown number of frames' @@ -229,6 +232,7 @@ def __init__(self, v=None, **kwds): EXAMPLES:: + sage: x = SR.var("x") sage: a = animate([sin(x + float(k)) for k in srange(0,2*pi,0.3)], ....: xmin=0, xmax=2*pi, figsize=[2,1]) # indirect doctest sage: a # optional -- ImageMagick @@ -404,7 +408,7 @@ def make_image(self, frame, filename, **kwds): ....: P = parametric_plot(frame[0], frame[1], **frame[2]) ....: P.save_image(filename,**kwds) - sage: t = var('t') + sage: t = SR.var("t") sage: x = lambda t: cos(t) sage: y = lambda n,t: sin(t)/n sage: B = MyAnimation([([x(t), y(i+1,t)],(t,0,1), {'color':Color((1,0,i/4)), 'aspect_ratio':1, 'ymax':1}) for i in range(4)]) @@ -451,6 +455,7 @@ def png(self, dir=None): EXAMPLES:: + sage: x = SR.var("x") sage: a = animate([plot(x^2 + n) for n in range(4)], ymin=0, ymax=4) sage: d = a.png(); v = os.listdir(d); v.sort(); v # long time ['00000000.png', '00000001.png', '00000002.png', '00000003.png'] @@ -507,7 +512,7 @@ def graphics_array(self, ncols=3): Frames can be specified as a generator too; it is internally converted to a list:: - sage: t = var('t') + sage: t = SR.var("t") sage: b = animate((plot(sin(c*pi*t)) for c in sxrange(1,2,.2))) sage: g = b.graphics_array() sage: g @@ -557,6 +562,7 @@ def gif(self, delay=20, savefile=None, iterations=0, show_path=False, EXAMPLES:: + sage: x = SR.var("x") sage: a = animate([sin(x + float(k)) for k in srange(0,2*pi,0.7)], ....: xmin=0, xmax=2*pi, ymin=-1, ymax=1, figsize=[2,1]) sage: td = tmp_dir() @@ -633,6 +639,7 @@ def _gif_from_imagemagick(self, savefile=None, show_path=False, EXAMPLES:: + sage: x = SR.var("x") sage: a = animate([sin(x + float(k)) for k in srange(0,2*pi,0.7)], ....: xmin=0, xmax=2*pi, ymin=-1, ymax=1, figsize=[2,1]) sage: td = tmp_dir() @@ -692,6 +699,7 @@ def _rich_repr_(self, display_manager, **kwds): EXAMPLES:: + sage: x = SR.var("x") sage: a = animate([plot(x^2 + n) for n in range(4)], ymin=0, ymax=4) sage: from sage.repl.rich_output import get_display_manager sage: dm = get_display_manager() @@ -784,6 +792,7 @@ def show(self, delay=None, iterations=None, **kwds): EXAMPLES:: + sage: x = SR.var("x") sage: a = animate([sin(x + float(k)) for k in srange(0,2*pi,0.7)], ....: xmin=0, xmax=2*pi, figsize=[2,1]) sage: a.show() # optional -- ImageMagick @@ -896,6 +905,7 @@ def ffmpeg(self, savefile=None, show_path=False, output_format=None, EXAMPLES:: + sage: x = SR.var("x") sage: a = animate([sin(x + float(k)) for k in srange(0,2*pi,0.7)], ....: xmin=0, xmax=2*pi, ymin=-1, ymax=1, figsize=[2,1]) sage: td = tmp_dir() @@ -1014,6 +1024,7 @@ def apng(self, savefile=None, show_path=False, delay=20, iterations=0): EXAMPLES:: + sage: x = SR.var("x") sage: a = animate([sin(x + float(k)) for k in srange(0,2*pi,0.7)], ....: xmin=0, xmax=2*pi, figsize=[2,1]) sage: dir = tmp_dir() @@ -1075,6 +1086,7 @@ def save(self, filename=None, show_path=False, use_ffmpeg=False, **kwds): EXAMPLES:: + sage: x = SR.var("x") sage: a = animate([sin(x + float(k)) for k in srange(0,2*pi,0.7)], ....: xmin=0, xmax=2*pi, ymin=-1, ymax=1, figsize=[2,1]) sage: td = tmp_dir() @@ -1153,6 +1165,7 @@ def interactive(self, **kwds): EXAMPLES:: + sage: x = SR.var("x") sage: frames = [point3d((sin(x), cos(x), x)) for x in (0, pi/16, .., 2*pi)] sage: animate(frames).interactive(online=True) Graphics3d Object @@ -1218,6 +1231,7 @@ class APngAssembler(object): EXAMPLES:: sage: from sage.plot.animate import APngAssembler + sage: x = SR.var("x") sage: def assembleAPNG(): ....: a = animate([sin(x + float(k)) for k in srange(0,2*pi,0.7)], ....: xmin=0, xmax=2*pi, figsize=[2,1])