【发布时间】:2017-06-06 18:17:22
【问题描述】:
我想用python3模块matplotlib画一个三角形。
import numpy as np
import matplotlib.pyplot as plt
X_train = np.array([[1,1], [2,2.5], [3, 1], [8, 7.5], [7, 9], [9, 9]])
Y_train = ['red', 'red', 'red', 'blue', 'blue', 'blue']
plt.figure()
plt.scatter(X_train[:, 0], X_train[:, 1], s = 170, color = Y_train[:])
plt.show()
它显示 6 个点,但它们分别分组在 2 个位置。 (颜色有助于看清楚)
有 2 组 3 个点。我希望每组(3个点)在三角形中统一。
如何实现这一点?如何使用 matplotlib 构建基于 3 个点的三角形?
欢迎提出任何建议;)
【问题讨论】:
标签: python-3.x matplotlib module figure