Skip to content

Commit 2ebdcd0

Browse files
committed
Change headings and update set_offsets description
1 parent 6c63bb3 commit 2ebdcd0

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

tutorials/introductory/animation_tutorial.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
# Animation Classes
1919
# =================
2020
#
21-
# The process of animation can be thought about in 2 different ways:
21+
# The process of animation in matplotlib can be thought about in 2 different
22+
# ways:
2223
#
2324
# - :class:`~matplotlib.animation.FuncAnimation`: Generate data for first
2425
# frame and then modify this data for each frame to create an animated plot.
@@ -49,8 +50,8 @@
4950
# :class:`~matplotlib.animation.FuncAnimation` with different artists.
5051

5152
###############################################################################
52-
# Animating :class:`~matplotlib.lines.Line2D`
53-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
53+
# Animating Lines
54+
# ^^^^^^^^^^^^^^^
5455
#
5556
# `.pyplot.plot` returns a :class:`~matplotlib.lines.Line2D` collection. The
5657
# data on this collection can be modified by using the
@@ -78,8 +79,8 @@ def update(frame):
7879
plt.show()
7980

8081
###############################################################################
81-
# Animating :class:`~matplotlib.collections.PathCollection`
82-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
82+
# Animating Markers
83+
# ^^^^^^^^^^^^^^^^^
8384
#
8485
# `.pyplot.scatter` returns a :class:`~matplotlib.collections.PathCollection`
8586
# that can similarly be modified by using the
@@ -93,13 +94,15 @@ def update(frame):
9394

9495
scat = ax.scatter(np.sin(a * t[0] + delta), np.sin(b * t[0]), c="b", s=2)
9596
ax.grid()
96-
ax.set_xlim(-1, 1)
97-
ax.set_ylim(-1, 1)
97+
ax.set_xlim(-1.5, 1.5)
98+
ax.set_ylim(-1.5, 1.5)
9899

99100

100101
def update(frame):
101-
# .set_offsets also resets the entire data for the collection.
102-
# Therefore, we create the entire data in each frame to draw
102+
# .set_offsets also resets the offset data for the entire collection with
103+
# the new values. Therefore, to also carry forward the previously
104+
# calculated information, we use the data from the first to the current
105+
# frame to set the new offsets.
103106
x = np.sin(a * t[:frame] + delta)
104107
y = np.sin(b * t[:frame])
105108
data = np.stack([x, y]).T
@@ -112,8 +115,8 @@ def update(frame):
112115

113116

114117
###############################################################################
115-
# Animating :class:`~matplotlib.image.AxesImage`
116-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
118+
# Animating Images
119+
# ^^^^^^^^^^^^^^^^
117120
#
118121
# When we plot an image using `.pyplot.imshow`, it returns an
119122
# :class:`~matplotlib.image.AxesImage` object. The data in this object can also

0 commit comments

Comments
 (0)