From 4ad92514f8d474f375d1d16588316a427f6ce760 Mon Sep 17 00:00:00 2001 From: yangyonggit Date: Wed, 17 May 2023 10:41:51 +0800 Subject: [PATCH] =?UTF-8?q?-=E4=BF=AE=E6=AD=A3=E4=BA=86=EF=BC=8C=E5=9B=BE?= =?UTF-8?q?=E5=83=8F=E6=B2=A1=E7=94=BB=E5=9C=A8=E4=B8=80=E5=BC=A0=E7=94=BB?= =?UTF-8?q?=E5=B8=83=E4=B8=8A=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Book4_Ch08_Python_Codes/Bk4_Ch8_01.py | 2 ++ Book4_Ch08_Python_Codes/Bk4_Ch8_02.py | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Book4_Ch08_Python_Codes/Bk4_Ch8_01.py b/Book4_Ch08_Python_Codes/Bk4_Ch8_01.py index be711ae..f5a6856 100644 --- a/Book4_Ch08_Python_Codes/Bk4_Ch8_01.py +++ b/Book4_Ch08_Python_Codes/Bk4_Ch8_01.py @@ -71,3 +71,5 @@ def plot_shape(X,copy = False): ax.spines['left'].set_visible(False) plt.xlabel('$x_1$') plt.ylabel('$x_2$') + +plt.show() \ No newline at end of file diff --git a/Book4_Ch08_Python_Codes/Bk4_Ch8_02.py b/Book4_Ch08_Python_Codes/Bk4_Ch8_02.py index 1a83b33..92d3ab0 100644 --- a/Book4_Ch08_Python_Codes/Bk4_Ch8_02.py +++ b/Book4_Ch08_Python_Codes/Bk4_Ch8_02.py @@ -27,6 +27,8 @@ def plot_shape(X,copy = False): markeredgecolor = edge_color*0.5, linestyle = 'None') + + X = np.array([[1,1], [0,-1], [-1,-1], @@ -35,12 +37,11 @@ def plot_shape(X,copy = False): # visualizations thetas = np.linspace(30, 330, num=11) +fig, ax = plt.subplots() -for theta in thetas: +for theta in thetas: - fig, ax = plt.subplots() - - theta = theta/180*np.pi; + theta = theta/180*np.pi # rotation R = np.array([[np.cos(theta), np.sin(theta)], [-np.sin(theta), np.cos(theta)]]) @@ -66,3 +67,5 @@ def plot_shape(X,copy = False): ax.spines['left'].set_visible(False) plt.xlabel('$x_1$') plt.ylabel('$x_2$') + +plt.show()