Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ffb9d3

Browse files
committed
BUG: Fix ordering in radar chart example.
Since dict keys are not guaranteed to be sorted, the various subplots would get each case at random.
1 parent ed44362 commit 4ffb9d3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/api/radar_chart.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,25 @@ def example_data():
136136
'column names':
137137
['Sulfate', 'Nitrate', 'EC', 'OC1', 'OC2', 'OC3', 'OP', 'CO',
138138
'O3'],
139-
'Basecase':
139+
(0, 'Basecase'):
140140
[[0.88, 0.01, 0.03, 0.03, 0.00, 0.06, 0.01, 0.00, 0.00],
141141
[0.07, 0.95, 0.04, 0.05, 0.00, 0.02, 0.01, 0.00, 0.00],
142142
[0.01, 0.02, 0.85, 0.19, 0.05, 0.10, 0.00, 0.00, 0.00],
143143
[0.02, 0.01, 0.07, 0.01, 0.21, 0.12, 0.98, 0.00, 0.00],
144144
[0.01, 0.01, 0.02, 0.71, 0.74, 0.70, 0.00, 0.00, 0.00]],
145-
'With CO':
145+
(1, 'With CO'):
146146
[[0.88, 0.02, 0.02, 0.02, 0.00, 0.05, 0.00, 0.05, 0.00],
147147
[0.08, 0.94, 0.04, 0.02, 0.00, 0.01, 0.12, 0.04, 0.00],
148148
[0.01, 0.01, 0.79, 0.10, 0.00, 0.05, 0.00, 0.31, 0.00],
149149
[0.00, 0.02, 0.03, 0.38, 0.31, 0.31, 0.00, 0.59, 0.00],
150150
[0.02, 0.02, 0.11, 0.47, 0.69, 0.58, 0.88, 0.00, 0.00]],
151-
'With O3':
151+
(2, 'With O3'):
152152
[[0.89, 0.01, 0.07, 0.00, 0.00, 0.05, 0.00, 0.00, 0.03],
153153
[0.07, 0.95, 0.05, 0.04, 0.00, 0.02, 0.12, 0.00, 0.00],
154154
[0.01, 0.02, 0.86, 0.27, 0.16, 0.19, 0.00, 0.00, 0.00],
155155
[0.01, 0.03, 0.00, 0.32, 0.29, 0.27, 0.00, 0.00, 0.95],
156156
[0.02, 0.00, 0.03, 0.37, 0.56, 0.47, 0.87, 0.00, 0.00]],
157-
'CO & O3':
157+
(3, 'CO & O3'):
158158
[[0.87, 0.01, 0.08, 0.00, 0.00, 0.04, 0.00, 0.00, 0.01],
159159
[0.09, 0.95, 0.02, 0.03, 0.00, 0.01, 0.13, 0.06, 0.00],
160160
[0.01, 0.02, 0.71, 0.24, 0.13, 0.16, 0.00, 0.50, 0.00],
@@ -175,12 +175,12 @@ def example_data():
175175

176176
colors = ['b', 'r', 'g', 'm', 'y']
177177
# Plot the four cases from the example data on separate axes
178-
for n, title in enumerate(data.keys()):
178+
for (n, title), case_data in sorted(data.items()):
179179
ax = fig.add_subplot(2, 2, n + 1, projection='radar')
180180
plt.rgrids([0.2, 0.4, 0.6, 0.8])
181181
ax.set_title(title, weight='bold', size='medium', position=(0.5, 1.1),
182182
horizontalalignment='center', verticalalignment='center')
183-
for d, color in zip(data[title], colors):
183+
for d, color in zip(case_data, colors):
184184
ax.plot(theta, d, color=color)
185185
ax.fill(theta, d, facecolor=color, alpha=0.25)
186186
ax.set_varlabels(spoke_labels)

0 commit comments

Comments
 (0)