Skip to content

Commit f376513

Browse files
committed
re-instate indenting of metric levels
1 parent 755d477 commit f376513

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

pypop/metrics/metricset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def __init__(self, key, level, displayname=None, desc=None, is_inefficiency=Fals
3131
self.is_inefficiency = is_inefficiency
3232

3333
if displayname:
34-
self.displayname = r"$\hookrightarrow$" * bool(self.level) + displayname
34+
self.displayname = r"" * bool(self.level) + displayname
3535
else:
36-
self.displayname = r"$\hookrightarrow$" * bool(self.level) + self.key
36+
self.displayname = r"" * bool(self.level) + self.key
3737

3838

3939
class MetricSet:

pypop/notebook_interface/plotting.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ def _setup_geometry(self):
166166
self._logo_height = 50
167167
self._logo_subpad = 10
168168
self._cell_height = font_px * 2.2
169+
self._border_pad = 10 # px
170+
self._left_pad = font_px / 2
171+
self._right_pad = font_px / 3
169172
self._row_locs = numpy.linspace(
170173
0, -self._cell_height * (self._nrows - 1), self._nrows
171174
)
@@ -192,10 +195,10 @@ def _setup_geometry(self):
192195

193196
# metric name widths
194197
for metric in self._metrics.metrics:
195-
self._metric_name_column_text.append(metric.key)
198+
self._metric_name_column_text.append(metric.displayname)
196199
self._metric_descriptions.append(metric.description)
197200
max_metric_em_width = max(
198-
max_metric_em_width, approx_string_em_width(metric.key)
201+
max_metric_em_width, approx_string_em_width(metric.displayname)
199202
)
200203

201204
# Calculate required value column width
@@ -205,9 +208,6 @@ def _setup_geometry(self):
205208
max_value_em_width, approx_string_em_width("{}".format(keyname))
206209
)
207210

208-
self._border_pad = 10 # px
209-
self._left_pad = font_px / 2
210-
self._right_pad = font_px / 3
211211
self._metric_column_width = 1.1 * (
212212
max_metric_em_width * font_px + self._left_pad + self._right_pad
213213
)
@@ -289,6 +289,7 @@ def _build_plot(self):
289289
"top_edges": numpy.full(
290290
num_groups, self._row_locs[0] + self._cell_height
291291
),
292+
"text_inset": self._left_pad,
292293
"bottom_edges": numpy.full(num_groups, self._row_locs[0]),
293294
"cell_fills": numpy.full(num_groups, RGB(255, 255, 255)),
294295
"data": [self._group_label]
@@ -300,13 +301,18 @@ def _build_plot(self):
300301
)
301302
)
302303

304+
metric_insets = [self._left_pad] + [
305+
self._left_pad * (1 + 1.5 * m.level) for m in self._metrics.metrics
306+
]
307+
303308
# Label column
304309
plotdata.append(
305310
pandas.DataFrame(
306311
{
307312
"left_edges": numpy.zeros(self._nrows),
308313
"right_edges": numpy.full(self._nrows, self._metric_column_width),
309314
"top_edges": self._row_locs,
315+
"text_inset": metric_insets,
310316
"bottom_edges": self._row_locs - self._cell_height,
311317
"cell_fills": numpy.full(self._nrows, RGB(255, 255, 255)),
312318
"data": self._metric_name_column_text,
@@ -329,6 +335,7 @@ def _build_plot(self):
329335
"left_edges": left_edges,
330336
"right_edges": right_edges,
331337
"top_edges": self._row_locs,
338+
"text_inset": self._left_pad,
332339
"bottom_edges": self._row_locs - self._cell_height,
333340
"cell_fills": [RGB(255, 255, 255)]
334341
+ [
@@ -363,7 +370,7 @@ def _build_plot(self):
363370
self._figure.text(
364371
x="left_edges",
365372
y="top_edges",
366-
x_offset=self._left_pad,
373+
x_offset="text_inset",
367374
y_offset=self._cell_height / 2,
368375
text="data",
369376
source=plotdata,

0 commit comments

Comments
 (0)