Skip to content

Commit 2f83e1c

Browse files
committed
Update lecture code
1 parent a2ee71b commit 2f83e1c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

res/lecture-code/lecture-9.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ def f(t):
6565
plt.show()
6666

6767

68+
def object_oriented_plotting():
69+
"""
70+
An example of object-oriented Matplotlib.
71+
"""
72+
fig = plt.figure()
73+
print(type(fig)) # => matplotlib.figure.Figure
74+
75+
ax = fig.add_subplot(1, 1, 1)
76+
print(type(ax)) # => matplotlib.axes._subplots.AxesSubplot
77+
78+
ax.plot([1, 4, 9, 16])
79+
plt.show()
80+
81+
6882
def histogram():
6983
"""
7084
Plot a histogram.
@@ -101,6 +115,7 @@ def main():
101115
simple_plot()
102116
plot_customizations()
103117
multiple_subplots()
118+
object_oriented_plotting()
104119
histogram()
105120
scatter_plot()
106121

0 commit comments

Comments
 (0)