我有一系列的测量值,我想绘制为pandas.plotting.parallel_坐标,其中每条线的颜色由一个pandas.column的值给出
代码如下所示:
... data retrieval and praparation from a couple of Excel files
---> output = 'largeDataFrame'
theColormap: ListedColormap = cm.get_cmap('some cmap name')
# This is a try to stack the lines in the right order.. (doesn't work)
largeDataFrames.sort_values(column_for_line_color_derivation, inplace=True, ascending=True)
# here comes the actual plotting of data
sns.set_style('ticks')
sns.set_context('paper')
plt.figure(figsize=(10, 6))
thePlot: plt.Axes = parallel_coordinates(largeDataFrame, class_column=column_for_line_color_derivation, cols=[columns to plot], color=theColormap.colors)
plt.title('My Title')
thePlot.get_legend().remove()
plt.xticks(rotation=90)
plt.tight_layout()
plt.show()
这项工作非常有效,并产生以下结果:
现在我想把黄线(高值的“column_for_line_color_derivation”)绘制在绿色和深色线的前面,这样它们会变得更加突出。换句话说,我想通过“column\u for\u line\u color\u derivation”的值来影响行的堆叠顺序。到目前为止,我还没有找到一种方法来做到这一点
我使用pandas版本1.1.2和1.0.3运行了一些测试,在这两种情况下,线都是从着色列的低值到高值绘制的,与数据帧顺序无关
您可以临时添加
parallel_coordinates(...., lw=5)
,这非常清楚。对于细线,顺序不太明显,因为黄线的对比度较小参数
sort_labels=
似乎与其名称具有相反的效果:当False
(默认)时,线按排序顺序绘制,当True
时,它们保持数据帧顺序以下是一个可重复的小示例:
一个想法是根据类别更改线宽:
相关问题 更多 >
编程相关推荐