【发布时间】:2020-01-05 21:49:21
【问题描述】:
每个 x 点我有 2 y 点。我可以用这段代码画出情节:
import matplotlib.pyplot as plt
x = [0, 2, 4, 6]
y = [(1, 5), (1, 3), (2, 4), (2, 7)]
plt.plot(x, [i for (i,j) in y], 'rs', markersize = 4)
plt.plot(x, [j for (i,j) in y], 'bo', markersize = 4)
plt.xlim(xmin=-3, xmax=10)
plt.ylim(ymin=-1, ymax=10)
plt.xlabel('ID')
plt.ylabel('Class')
plt.show()
这是输出:
如何画一条连接每个 y 点对的细线?期望的输出是:
【问题讨论】:
标签: python matplotlib plot scatter-plot