回答編集履歴
1
コメントを受けて回答を修正
answer
CHANGED
@@ -13,4 +13,32 @@
|
|
13
13
|
ax.set_ylabel('Rate')
|
14
14
|
plt.show()
|
15
15
|
```
|
16
|
-

|
16
|
+

|
17
|
+
|
18
|
+
---
|
19
|
+
**追記**
|
20
|
+
|
21
|
+
```Python
|
22
|
+
import pandas as pd
|
23
|
+
import matplotlib.pyplot as plt
|
24
|
+
|
25
|
+
df = pd.DataFrame({'Sample No.':[1,2,3,4,5,6],
|
26
|
+
'Black':[30,45,10,15,40,30],
|
27
|
+
'Green': [20,30,60,40,45,45],
|
28
|
+
'Red': [50,25,30,45,15,25]})
|
29
|
+
df['Pos'] = [0,1,3,4,6,7]
|
30
|
+
|
31
|
+
ax = plt.subplot()
|
32
|
+
ax.bar(x=df['Pos'], height=df['Red'], bottom=0, color='red', label='Red')
|
33
|
+
ax.bar(x=df['Pos'], height=df['Green'], bottom=df['Red'], color='green', label='Green')
|
34
|
+
ax.bar(x=df['Pos'], height=df['Black'], bottom=df['Red']+df['Green'], color='black', label='Black')
|
35
|
+
|
36
|
+
ax.set_xticks(df['Pos'])
|
37
|
+
ax.set_xticklabels(df['Sample No.'])
|
38
|
+
ax.set_xlabel('Sample No.')
|
39
|
+
ax.set_ylabel('Rate')
|
40
|
+
ax.legend()
|
41
|
+
plt.savefig('out2.png')
|
42
|
+
plt.show()
|
43
|
+
```
|
44
|
+

|