回答編集履歴

1

コメントを受けて回答を修正

2020/01/12 03:59

投稿

magichan
magichan

スコア15898

test CHANGED
@@ -29,3 +29,59 @@
29
29
  ```
30
30
 
31
31
  ![イメージ説明](26a5444f4ed26c1eaf54aefc33f4adea.png)
32
+
33
+
34
+
35
+ ---
36
+
37
+ **追記**
38
+
39
+
40
+
41
+ ```Python
42
+
43
+ import pandas as pd
44
+
45
+ import matplotlib.pyplot as plt
46
+
47
+
48
+
49
+ df = pd.DataFrame({'Sample No.':[1,2,3,4,5,6],
50
+
51
+ 'Black':[30,45,10,15,40,30],
52
+
53
+ 'Green': [20,30,60,40,45,45],
54
+
55
+ 'Red': [50,25,30,45,15,25]})
56
+
57
+ df['Pos'] = [0,1,3,4,6,7]
58
+
59
+
60
+
61
+ ax = plt.subplot()
62
+
63
+ ax.bar(x=df['Pos'], height=df['Red'], bottom=0, color='red', label='Red')
64
+
65
+ ax.bar(x=df['Pos'], height=df['Green'], bottom=df['Red'], color='green', label='Green')
66
+
67
+ ax.bar(x=df['Pos'], height=df['Black'], bottom=df['Red']+df['Green'], color='black', label='Black')
68
+
69
+
70
+
71
+ ax.set_xticks(df['Pos'])
72
+
73
+ ax.set_xticklabels(df['Sample No.'])
74
+
75
+ ax.set_xlabel('Sample No.')
76
+
77
+ ax.set_ylabel('Rate')
78
+
79
+ ax.legend()
80
+
81
+ plt.savefig('out2.png')
82
+
83
+ plt.show()
84
+
85
+ ```
86
+
87
+ ![イメージ説明](6bf4bf3d01c299d5780a44d775a39d82.png)