突出显示并行坐标图的特定数据点
我正在寻找帮助/颜色的特定数据点在并行坐标图上。我似乎找不到方法。
本质上,我想绘制所有数据如下,然后取,例如,数据点的索引[0,1,2]并为它们涂上第三种颜色以突出显示它们(如果可能的话,也会使它们更厚吗?)建议?
from sklearn import datasets
from yellowbrick.features import ParallelCoordinates
iris = datasets.load_iris()
X = iris.data[:, :]
y = iris.target
features = ['sepal_length', 'sepal_width', 'petal_length', 'petal_width']
classes = ['Iris-setosa', 'Iris-versicolor', 'Iris-virginica']
title = "Plot over Iris Data"
# Instantiate the visualizer
visualizer = ParallelCoordinates(
classes=classes, features=features, fast=False, alpha=.40, title=title)
# Fit the visualizer and display it
visualizer.fit_transform(X, y)
visualizer.finalize() # creates title, legend, etc.
visualizer.ax.tick_params(labelsize=22) # change size of tick labels
visualizer.ax.title.set_fontsize(30) # change size of title
for text in visualizer.ax.legend_.texts: # change size of legend texts
text.set_fontsize(20)
visualizer.fig.tight_layout() # fit all texts nicely into the surrounding figure
visualizer.fig.show()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当前, 按顺序迭代数据点。因此,儿童
line2d
可视化器的实例
将遵循数据的顺序。因此,您可以做:结果:
因此,(即使我不期望)他们将在以后的更新中改变这种行为。一种更安全的方法是手动检查该行的数据是否匹配可视化器使用的转换数据。请注意,我们需要通常使用转换的数据,因为
ParallelCoordinates
还实现了正常人。这不是您的情况,但总的来说,我们应该这样做:Currently,
ParallelCoordinates.draw()
iterates the datapoints in order. Hence, the childLine2D
instances ofvisualizer.ax
will follow the order of the data. Hence, you can do:Result:
Please note that the fact that lines are added in-order is not written in the documentation, it's just how it is implemented. Hence, it could be (even though I don't expect it) that they will change this behavior in future updates. A safer way would be to manually check whether the line's data matches the transformed data used by the visualizer. Note that we need to use the transformed data in general, because
ParallelCoordinates
also implements a normaliser. It's not your case, but in general we should do so: