Closed lang07123 closed 3 months ago
你是对的,本来是想让读者自己探索,在原来代码上修改。下一版应该采用子图方式,也就是你建议的代码。请继续批评指正。
On Mon, Jul 24, 2023 at 3:17 AM lang07123 @.***> wrote:
[image: 图片] https://user-images.githubusercontent.com/7733095/255512922-99f92b70-82ea-4610-9f0e-6840e69993dd.png 只显示了一张图片, 没有其它的图,
附修改后的代码:
###############
Authored by Weisheng Jiang
Book 3 | From Basic Arithmetic to Machine Learning
Published and copyrighted by Tsinghua University Press
Beijing, China, 2022
###############
Bk3_Ch14_02
import numpy as np from matplotlib import pyplot as plt
a = 1 # initial term n = 50 # number of terms q_list = [1.1, 1, 0.9, -0.9, -1, -1.1]
fig = plt.figure(figsize=(20, 8))
for pos, q in enumerate(q_list):
Generate geometric progression, GP, sequence
GP_sequence = [a*q**i for i in range(n)] index = np.arange(1, n + 1, 1) ax = fig.add_subplot(2, 3, pos+1) ax.set_xlabel("Index, $k$") ax.set_ylabel("Term, $a_k$") ax.plot(index, GP_sequence, marker='.', markersize=6, linestyle='None') ax.grid(linestyle='--', linewidth=0.25, color=[0.5, 0.5, 0.5])
plt.show()
— Reply to this email directly, view it on GitHub https://github.com/Visualize-ML/Book3_Elements-of-Mathematics/issues/115, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZHC6V7CYXSDHLQMXS4XFGDXRYOPBANCNFSM6AAAAAA2VES7UM . You are receiving this because you are subscribed to this thread.Message ID: @.***>
附修改后的代码: