# 利用Python Matlab绘制曲线图的简单实例

## 二、绘制图形

### 1、第一个曲线图

import matplotlib.pyplot as plt
import numpy as np

r = np.array([2072.54, 2076.84, 2085.51, 2103.01, 2129.93, 2162.16, 2200.22, 2242.15,
2285.71, 2328.29, 2350.18, 2364.01, 2364.01, 2343.29, 2300.17, 2252.25,
2208.72, 2166.85, 2132.19, 2103.01, 2085.51, 2075.77, 2072.54])
b_ = np.array([30.159, 27.143, 24.127, 21.111, 18.096, 15.080, 12.064, 9.048,
6.032, 3.016, 1.508, 0, -1.508, -3.016, -6.032, -9.048, -12.064,
-15.080, -18.096, -21.111, -24.127, -27.143, -30.159])
b = b_ * pow(10, -4)

plt.plot(b, r)
plt.xlabel("B/T")
plt.ylabel("R/Ω")
plt.title("GMB R-B (decreasing B)")
plt.show()

### 2、第二个图形

import matplotlib.pyplot as plt
import numpy as np

r = np.array([2072.53, 2076.81, 2085.47, 2103.00, 2129.90, 2162.11, 2200.20, 2242.06,
2285.66, 2328.24, 2350.13, 2364.00, 2363.96, 2343.19, 2300.20, 2252.29,
2208.76, 2166.89, 2132.20, 2103.05, 2085.50, 2075.81, 2072.56])
b_ = np.array([30.159, 27.143, 24.127, 21.111, 18.096, 15.080, 12.064, 9.048,
6.032, 3.016, 1.508, 0, -1.508, -3.016, -6.032, -9.048, -12.064,
-15.080, -18.096, -21.111, -24.127, -27.143, -30.159])
b = b_ * pow(10, -4)

plt.plot(b, r)
plt.xlabel("B/T")
plt.ylabel("R/Ω")
plt.title("GMB R-B (increasing B)")
plt.show()

### 3、第三个图形

import matplotlib.pyplot as plt
import numpy as np

v = np.array([274, 270, 261, 243, 219, 189, 155, 118, 81, 48, 34, 21])
b_ = np.array([30.159, 27.143, 24.127, 21.111, 18.096, 15.080, 12.064, 9.048,
6.032, 3.016, 1.508, 0])
b = b_ * pow(10, -4)

plt.plot(b, v)
plt.xlabel("B/T")
plt.ylabel("V/mV")
plt.title("GMB V-B")
plt.show()

### 4、第四个图形

import matplotlib.pyplot as plt
import numpy as np

w = np.array([43.5, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86,
89, 92, 95, 98, 101, 104])
v = np.array([0, 5.7, 35.0, 53.8, 45.9, 7.7, -45.7, -51.9, -32.6, -1.8, 34.5, 53.1,
39.2, -10.1, -47.9, -51.4, -29.5, 5.6, 34.4, 52.4, 40.9, -5.2])

plt.plot(w, v)
plt.ylabel("V/mV")
plt.title("GMB V-θ")
plt.show()

### 5.画出指定区间的一个多项式函数：

import numpy as np

import matplotlib.pyplot as plt

X = np.linspace(-4, 4, 1024)

Y = .25 * (X + 4.) * (X + 1.) * (X - 2.)

plt.title("\$f(x)=frac{1}{4}(x+4)(x+1)(x-2)\$")

plt.plot(X, Y, c = "g")

plt.show()