Files
nn/plot.ipynb
2026-04-22 15:23:35 +08:00

525 KiB

In [6]:
import matplotlib
import numpy as np

print(matplotlib.__version__)
3.7.2
In [7]:
from matplotlib import pyplot as plt
In [6]:
xpoints = np.array([0,6])
ypoints = np.array([0,100])
In [7]:
plt.plot(xpoints,ypoints)
Out [7]:
[<matplotlib.lines.Line2D at 0x7f670479bcb0>]
In [8]:
xpoints = np.array([1, 8])
ypoints = np.array([3, 10])

plt.plot(xpoints, ypoints)
plt.show()
In [9]:
xpoints = np.array([1, 8])
ypoints = np.array([3, 10])

plt.plot(xpoints, ypoints, 'o')
plt.show()
In [10]:
xpoints = np.array([1, 2, 6, 8])
ypoints = np.array([3, 8, 1, 10])

plt.plot(xpoints, ypoints)
plt.show()
In [11]:
ypoints = np.array([3, 10])

plt.plot(ypoints)
plt.show()
In [12]:
x = np.arange(0,4*np.pi,0.1)   # start,stop,step
y = np.sin(x)
z = np.cos(x)
plt.plot(x,y,x,z)
plt.show()
In [13]:
x = np.array([1, 2, 3, 4])
y = np.array([1, 4, 9, 16])
plt.plot(x, y)

plt.xlabel("x - label")
plt.ylabel("y - label")
Out [13]:
Text(0, 0.5, 'y - label')
In [16]:
x = np.array([1, 2, 3, 4])
y = np.array([1, 4, 9, 16])
plt.plot(x, y)

plt.title("tittle")
plt.xlabel("x - label")
plt.ylabel("y - label")

plt.show()
In [24]:
import numpy as np
theta = np.linspace(0,2*np.pi,37)
theta
Out [24]:
array([0.        , 0.17453293, 0.34906585, 0.52359878, 0.6981317 ,
       0.87266463, 1.04719755, 1.22173048, 1.3962634 , 1.57079633,
       1.74532925, 1.91986218, 2.0943951 , 2.26892803, 2.44346095,
       2.61799388, 2.7925268 , 2.96705973, 3.14159265, 3.31612558,
       3.4906585 , 3.66519143, 3.83972435, 4.01425728, 4.1887902 ,
       4.36332313, 4.53785606, 4.71238898, 4.88692191, 5.06145483,
       5.23598776, 5.41052068, 5.58505361, 5.75958653, 5.93411946,
       6.10865238, 6.28318531])
In [35]:
r = np.array([0.007, 0.018, 0.042, 0.082, 0.127, 0.174, 0.222, 0.260, 0.277, 0.283, 0.276, 0.253, 0.214, 0.165, 0.116, 0.070, 0.037, 0.014, 0.007, 0.017, 0.043, 0.081, 0.131, 0.179, 0.226, 0.260, 0.283, 0.287, 0.270, 0.250, 0.209, 0.164, 0.115, 0.069, 0.034, 0.013, 0.007])
In [36]:
ax = plt.figure(figsize=(6, 6))
ax.patch.set_facecolor('#E6E6FA')
plt.polar(theta, r, marker='o', linestyle='-', color='blue', linewidth=2)
Out [36]:
[<matplotlib.lines.Line2D at 0x7f2edec84750>]
In [37]:
ax.savefig('./save1.png', dpi=300)
In [38]:
r=np.array([
    0.048, 0.059, 0.052, 0.059, 0.077, 0.102, 0.139, 0.173, 0.203, 0.231,
    0.250, 0.259, 0.255, 0.234, 0.205, 0.179, 0.159, 0.145, 0.076, 0.055,
    0.046, 0.050, 0.065, 0.092, 0.126, 0.164, 0.202, 0.233, 0.253, 0.261,
    0.257, 0.241, 0.211, 0.177, 0.143, 0.108, 0.077
])
In [39]:
bx = plt.figure(figsize=(6, 6))
bx.patch.set_facecolor('#E6E6FA')
plt.polar(theta, r, marker='o', linestyle='-', color='blue', linewidth=2)
bx.savefig('./save2.png', dpi=300)
In [40]:
r= np.array([
    0.158, 0.155, 0.154, 0.156, 0.156, 0.154, 0.158, 0.159, 0.156, 0.157,
    0.159, 0.161, 0.163, 0.163, 0.162, 0.165, 0.164, 0.162, 0.156, 0.154,
    0.150, 0.146, 0.142, 0.142, 0.144, 0.147, 0.152, 0.157, 0.160, 0.163,
    0.167, 0.169, 0.168, 0.168, 0.167, 0.163, 0.159
])
In [41]:
bx = plt.figure(figsize=(6, 6))
bx.patch.set_facecolor('#E6E6FA')
plt.polar(theta, r, marker='o', linestyle='-', color='blue', linewidth=2)
bx.savefig('./save3.png', dpi=300)
In [ ]: