From 9071cec11720e5040e6e6a4585cc8f2b04ae14c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=AD=E6=97=A5=E4=B8=9C=E5=8D=87?= <8113091+xrdspxd@user.noreply.gitee.com> Date: Mon, 19 Oct 2020 14:45:24 +0800 Subject: [PATCH] =?UTF-8?q?add=20homework=5F02=5Fnumpy=5Fmatplotlib/2.?= =?UTF-8?q?=EF=BC=883=EF=BC=89.text.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2.\357\274\2103\357\274\211.text" | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 "homework_02_numpy_matplotlib/2.\357\274\2103\357\274\211.text" diff --git "a/homework_02_numpy_matplotlib/2.\357\274\2103\357\274\211.text" "b/homework_02_numpy_matplotlib/2.\357\274\2103\357\274\211.text" new file mode 100644 index 0000000..eb4771d --- /dev/null +++ "b/homework_02_numpy_matplotlib/2.\357\274\2103\357\274\211.text" @@ -0,0 +1,16 @@ +import matplotlib.pyplot as plt +import numpy as np +a = [0, 0] +A = [a, ] +while len(A) < 1000: + p = np.array([[0, 1], [1, 0], [0, -1], [-1, 0]]) + b = np.random.randint(len(p)) + a = np.array(a) + p[b] + c = list(a) + A.append(c) +B = np.array(A).T +plt.scatter(0, 0, c='r') +plt.axis('off') +plt.plot(B[0], B[1], c='g') + +plt.show() -- Gitee