我在csv文件中有以下数据:
Date City TruckA TruckB TruckC TruckD
Date1 City1 1 0 0 0
Date1 City2 0 0 1 0
Date1 City3 1 0 0 0
Date1 City4 0 0 1 0
Date2 City1 1 0 0 0
Date2 City2 0 1 0 0
Date2 City3 0 0 0 1
Date2 City4 1 0 0 0
Date2 City5 0 1 0 0
Date3 City1 1 0 0 0
Date3 City2 0 0 1 0
Date3 City3 1 0 0 0
Date3 City4 0 0 1 0
我可以用以下代码成功绘制数据:
^{pr2}$我得到以下结果:
正如你所看到的,颜色的传奇是这样的每一对(城市,卡车)有一个颜色。我希望传奇只依赖于卡车,理想的是每个城市的条形图上都有标签。在
这可能吗?在
按照@Scott的回答,您可以得到所需的堆叠柱。在
要添加标签,您需要找到正确的位置并迭代地添加标签。
以下是一种方法:
编辑:仅一个循环
^{pr2}$原液
编辑
输出:
添加了edgecolor以区分城市:
^{pr2}$IIUC,我想你在找这样的东西:
输出:
相关问题 更多 >
编程相关推荐