plot([1,2,3,4])
: 當只傳入一組值的時候當作 y
plot([1,2,3,4], [1,4,9,16])
:兩個的時候作 x, y
plot([1,2,3,4], [1,4,9,16], "ro")
:x,y, fmt(點的樣式)
fmt = '[marker][line][color]'
, [color][marker][line]
are also supportedimport numpy as np
# evenly sampled time at 200ms intervals
t = np.arange(0., 5., 0.2)
# red dashes, blue squares and green triangles
plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')
plt.show()
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0, 10, 0.01)
y1 = np.sin(x)
y2 = np.cos(x)
plt.plot(x, y1, "-",label="Train")
plt.plot(x, y2, "-",label="Dev")
plt.legend()
plt.show()
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(1, 11, 0.1)
y = np.arange(1, 11, 0.1)
plt.figure(figsize=(15,5))
plt.subplot(1,3,1)
plt.plot(x, y,"-",label="y")
plt.legend()
plt.subplot(1,3,2)
plt.plot(x, np.log(y),"-",label="Log")
plt.legend()
plt.subplot(1,3,3)
plt.plot(x, np.exp(y),"-",label="Exp")
plt.legend()
plt.suptitle('MEOW')
plt.show()
subplot()
: n row, n column, index
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(1, 11, 0.1)
y = np.arange(1, 11, 0.1)
plt.figure(figsize=(10,10))
plt.subplot(211)
plt.plot(x, y,"r.",label="y")
plt.legend()
plt.subplot(212)
plt.plot(x, np.exp(y),"-",label="Exp")
plt.legend()
plt.suptitle('MEOW')
plt.show()