回答編集履歴
1
追記
test
CHANGED
@@ -87,3 +87,115 @@
|
|
87
87
|
**result.png**
|
88
88
|
|
89
89
|
![イメージ説明](0735da2832012115ff98cbc8eba2592f.png)
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
### 追記
|
96
|
+
|
97
|
+
上と同様にpandasでやろうとした・・・らなかなか思い通りにplotできなかったので、生matplotlibで書いてみたコード。コードの見た目はともかく、結果はこんな感じで良いでしょうか。
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
```python
|
102
|
+
|
103
|
+
import io
|
104
|
+
|
105
|
+
import pandas as pd
|
106
|
+
|
107
|
+
import matplotlib.pyplot as plt
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
txt = """
|
112
|
+
|
113
|
+
出力 制御A 制御B 制御C
|
114
|
+
|
115
|
+
100 2 8 1
|
116
|
+
|
117
|
+
100 2 5 1
|
118
|
+
|
119
|
+
150 3 4 9
|
120
|
+
|
121
|
+
150 3 5 6
|
122
|
+
|
123
|
+
200 5 2 7
|
124
|
+
|
125
|
+
200 5 2 7
|
126
|
+
|
127
|
+
170 2 8 1
|
128
|
+
|
129
|
+
170 2 8 1
|
130
|
+
|
131
|
+
80 2 8 9
|
132
|
+
|
133
|
+
"""
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
df = pd.read_table(io.StringIO(txt), delimiter="\t", header=0)
|
138
|
+
|
139
|
+
print(df)
|
140
|
+
|
141
|
+
""" =>
|
142
|
+
|
143
|
+
出力 制御A 制御B 制御C
|
144
|
+
|
145
|
+
0 100 2 8 1
|
146
|
+
|
147
|
+
1 100 2 5 1
|
148
|
+
|
149
|
+
2 150 3 4 9
|
150
|
+
|
151
|
+
3 150 3 5 6
|
152
|
+
|
153
|
+
4 200 5 2 7
|
154
|
+
|
155
|
+
5 200 5 2 7
|
156
|
+
|
157
|
+
6 170 2 8 1
|
158
|
+
|
159
|
+
7 170 2 8 1
|
160
|
+
|
161
|
+
8 80 2 8 9
|
162
|
+
|
163
|
+
"""
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
df["メイン制御"] = df.apply(lambda s: s.idxmin(), axis=1)
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
c_dict = {"制御A":"b", "制御B":"y", "制御C":"r"}
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
plt.figure()
|
176
|
+
|
177
|
+
for label in ["制御A","制御B","制御C"]:
|
178
|
+
|
179
|
+
tmp = df[df["メイン制御"]==label]
|
180
|
+
|
181
|
+
plt.bar(tmp.index, tmp["出力"],
|
182
|
+
|
183
|
+
color=c_dict[label],
|
184
|
+
|
185
|
+
label=label,
|
186
|
+
|
187
|
+
align="center")
|
188
|
+
|
189
|
+
plt.xticks(df.index)
|
190
|
+
|
191
|
+
plt.legend()
|
192
|
+
|
193
|
+
plt.savefig("result2.png")
|
194
|
+
|
195
|
+
```
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
**result2.png**
|
200
|
+
|
201
|
+
![イメージ説明](8b3fc395a34df3510c96de34484387b7.png)
|