1.基本折线图
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(30)
y = np.random.randn(30)
plt.plot(x, y)
plt.show()
2.双折线图
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(30)
y1 = np.random.randn(30)
y2 = np.random.randn(30)
plt.plot(x, y1)
plt.plot(x, y2)
plt.show()
3.折线图各种元素设置
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(30)
y1 = np.random.randn(30)
y2 = np.random.randn(30)
plt.style.use('ggplot')
plt.plot(x, y1, label="line1", color='c')
plt.plot(x, y2, label="line2", color='r')
plt.xlabel("X")
plt.ylabel("Y")
plt.xticks(rotation=45)
plt.title("title")
plt.grid(color='coral', ls='dashed', lw=0.5, alpha=0.5)
plt.legend()
plt.show()