VisibleBeforeBegin, VisibleAfterEnd

Object visible before or after its animation time starts?

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Value Summary

VisibleAfterEnd, VisibleBeforeBeginInheritedFALSE, or TRUE


VisibleBeforeBegin, VisibleAfterEnd determine the visibility of an object before the begin and after the end of its own animation time span, respectively.

Animations are defined object by object. Each animated object is animated for a certain time span specified by TimeBegin and TimeEnd setting the real start and end time in seconds.

The total real time span of an animated plot is the physical real time given by the minimum of the TimeBegin values of all animated objects in the plot to the maximum of the TimeEnd values of all the animated objects.

Thus, the time span of an animated plot may be larger than the time spans of the animations of individual objects.

With VisibleBeforeBegin = TRUE, an object is visible as a static object when the animation of the entire plot starts. Its state correponds to the start of its own animation. It begins to change, when the starting time of its own animation set by TimeBegin is reached.

With VisibleBeforeBegin = FALSE, an object is invisible when the animation of the entire plot starts. It becomes visible when the starting time of its own animation is reached.

With VisibleAfterEnd = TRUE, an object stays visible in the final state of its animation after the end of its own animation time span set by TimeEnd.

With VisibleAfterEnd = FALSE, an object becomes invisible at the end of its own animation.

VisibleBeforeBegin, VisibleAfterEnd is useful only in plots consisting of several animated objects with different time spans of their animations.

Also consider the attributes VisibleAfter, VisibleBefore, and VisibleFromTo to animate the visibility of objects.


Example 1

In the first 5 seconds of the following animation, the sine function draws itself. Afterwards, a point wanders along the graph:

f := plot::Function2d(sin(x), x = -PI..a, a = -PI..PI, 
                      TimeRange = 0..5):
p := plot::Point2d(a, sin(a), PointSize = 5*unit::mm, 
                   a = -PI..PI, TimeRange = 5..10):
plot(f, p)

The point is visible for the first 5 seconds, too, because it used the default setting VisibleBeforeBegin = TRUE. With VisibleBeforeBegin = FALSE, the point is invisible at the start of the animation. It appears after 5 seconds, when its own animation begins:

p::VisibleBeforeBegin := FALSE:
plot(f, p)

delete p, f:

Example 2

The plot::Polar object in the following animation is only visible in its TimeRange from the 3rd to the 7th second:

Speaker := 
     plot::Polygon2d([[0.5, -1], [0.5, 1], [0, 0.3], 
                     [-0.5, 0.3], [-0.5, -0.3], [0, -0.3], 
                     [0.5, -1]], Color = RGB::Black, Filled):
Point := plot::Point2d([2, a], a = -2.5..2.5, 
                       PointSize = 3*unit::mm):
plot(plot::Polar([1 + 0.1*(2 + sin(20*a))*cos(20*phi), phi],
                 phi = -1..1, a = 0..3, TimeRange = 3..7,
                 VisibleBeforeBegin = FALSE,
                 VisibleAfterEnd = FALSE),
     Speaker, Point, Axes = None)

The previous command is equivalent to:

plot(plot::Polar([1 + 0.1*(2 + sin(20*a))*cos(20*phi), phi],
                 phi = -1..1, a = 0..3, VisibleFromTo = 3..7),
     Speaker, Point, Axes = None)

delete Speaker, Point:

Example 3

A circle is tumbling around in 3D. After 3 seconds, a growing sphere becomes visible. From the 5th second through to the end of the animation, the sphere stays visible with the constant radius 5, while the circle moves further out:

plot(plot::Circle3d(4, [sin(a), cos(a), a], 
                    [sin(a), cos(a), a], a = 0..10, 
                    Frames = 100, TimeRange = 0..10,
                    Filled = TRUE, FillColor = RGB::Blue),
     plot::Sphere(a, [0, 0, 0], Color=RGB::Red,
                  a = 3..5, TimeRange = 3 .. 5, Frames = 20,
                  VisibleBeforeBegin = FALSE)):