制作一些数据来演示。
import numpy as np
from matplotlib import pyplot as plt
x = np.matrix(
[
[1, 1, 1, 1],
[2, 2, 2, 2],
[3, 3, 3, 3],
[4, 4, 4, 4]
]
)
y = x.transpose()
# Vertical Lines of grid:
plt.plot(x, y, 'b-o')
plt.show()
# Horizontal Lines
plt.plot(x, y, 'b-o')
plt.show()
# Together (this is what I think you want)
plt.plot(y, x, 'b-o')
plt.plot(x, y, 'b-o')
plt.show()
如果你试着把它们连接起来在一个大矩阵中,它会做一些看似愚蠢的事情,把我们真正不想连接的几个点连接起来。
# sillyness
x1 = np.concatenate((x, y), axis=0)
y1 = np.concatenate((y, x), axis=0)
plt.plot(x1, y1, 'b-o')
plt.show()