Skip to content

Commit 352b31c

Browse files
committed
improve grouping logic for plotting
1 parent 9d6719b commit 352b31c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

pypop/notebook_interface/plotting.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def __init__(
125125
metrics: MetricSet,
126126
columns_key="auto",
127127
group_key="auto",
128+
group_label=None,
128129
title=None,
129130
columns_label=None,
130131
fontsize=14,
@@ -140,6 +141,8 @@ def __init__(
140141
self._metrics._default_group_key if group_key == "auto" else group_key
141142
)
142143

144+
self._group_label = group_label if group_label else self._group_key
145+
143146
self._fontsize = fontsize
144147
self._metric_name_column_text = []
145148
self._metric_descriptions = []
@@ -277,7 +280,7 @@ def _build_plot(self):
277280
),
278281
"bottom_edges": numpy.full(num_groups, self._row_locs[0]),
279282
"cell_fills": numpy.full(num_groups, RGB(255, 255, 255)),
280-
"data": [self._group_key]
283+
"data": [self._group_label]
281284
+ ["{}".format(g[0]) for g in group_iter],
282285
"short_desc": [self._group_key] * num_groups,
283286
"long_desc": [self._metrics._key_descriptions[self._group_key]]
@@ -394,6 +397,7 @@ def __init__(
394397
scaling_variable="Speedup",
395398
independent_variable="auto",
396399
group_key="auto",
400+
group_label=None,
397401
title=None,
398402
fontsize=14,
399403
**kwargs
@@ -406,6 +410,8 @@ def __init__(
406410
self._metrics._default_group_key if group_key == "auto" else group_key
407411
)
408412

413+
self._group_label = group_label if group_label else self._group_key
414+
409415
self._xaxis_key = (
410416
self._metrics._default_scaling_key
411417
if independent_variable == "auto"
@@ -433,16 +439,13 @@ def _build_plot(self):
433439
.copy()
434440
)
435441
plot_data["Plotgroups"] = plot_data[self._group_key].apply(
436-
lambda x: "{} {}".format(x, self._group_key)
442+
lambda x: "{} {}".format(x, self._group_label)
437443
)
438-
444+
439445
else:
440-
plot_data = (
441-
self._metrics.metric_data[
442-
[self._xaxis_key, self._yaxis_key]
443-
]
444-
.copy()
445-
)
446+
plot_data = self._metrics.metric_data[
447+
[self._xaxis_key, self._yaxis_key]
448+
].copy()
446449
plot_data["Plotgroups"] = "NULL"
447450

448451
color_map = build_discrete_cmap(plot_data["Plotgroups"].unique())

0 commit comments

Comments
 (0)