Python Stackplot异常

时间:2019-06-11 16:49:52

标签: python pandas stack

我在Excel中有一个堆栈图,如下所示。我正在尝试使用Python生成相同的图。

enter image description here

我的相同代码如下。

x = ['d1','d2','d3','d4','d5']
labels = ['a','b','c','d','e']
sns.set(font_scale = 1.25)
plt.stackplot(x,gA,gB,gC,gD,gE,labels=labels) #gA,...,gE stores the percentage values
plt.legend(loc='upper left')
plt.title('Reason')
plt.show()

样本y-gB如下所示

+---+--------+
|   | Reason |
+---+--------+
| a |      4 |
| b |     32 |
| c |      4 |
| d |     56 |
| e |      4 |
+---+--------+

运行此命令会得到一个非常奇怪的情节。

enter image description here

我错过了什么?

0 个答案:

没有答案