我尝试创建一个parallel_coordinates图,其中的线条颜色指示一个信号的值。情节的输出很好:

但我想在这个情节中添加一个色条传说来解释颜色的含义。
thePlot: plt.Axes = parallel_coordinates(myDataFrame, class_column=class_column, cols=plotColumns, colormap='hot')
plt.colorbar(thePlot)使用AttributeError: 'AxesSubplot' object has no attribute 'get_array'崩溃,以及
thePlot: plt.Axes = parallel_coordinates(myDataFrame, class_column=class_column, cols=plotColumns, colormap='hot')
plt.colorbar()崩溃使用:RuntimeError: No mappable was found to use for colorbar creation. First define a mappable such as an image (with imshow) or a contour set (with contourf).
如何添加一个彩色条作为传奇?
发布于 2020-10-05 19:50:01
parallel_coordinates创建了许多单独的短线,每一行都有自己的颜色。因此,不存在包含信息的元素来创建一个色条。
您可以使用相同的参数从头开始创建一个色条:
from matplotlib.cm import ScalarMappable
plt.colorbar(ScalarMappable(norm=plt.Normalize(df['coloring'].min(), df['coloring'].max()), cmap='hot'), ax=thePlot)https://stackoverflow.com/questions/64214939
复制相似问题