Skip to content

Commit 436baf0

Browse files
committed
Update the legend drawing to remove unnecessary space
1 parent 61c7ce4 commit 436baf0

5 files changed

Lines changed: 6 additions & 7 deletions

File tree

-29 Bytes
Binary file not shown.
-22 Bytes
Binary file not shown.

multiplex/drawable.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def _redraw_caption(self):
168168
"""
169169
Move the caption up to make space for the legend and the label.
170170
"""
171-
y = 1
171+
y = 1.015
172172
y += self.legend.get_virtual_bb(transform=self.axes.transAxes).height
173173

174174
"""
@@ -183,9 +183,8 @@ def _redraw_caption(self):
183183
if xtick_labels_bb:
184184
y += max(xtick_labels_bb, key=lambda bb: bb.height).height * 2
185185

186-
pad = 0.1
187186
self.caption.redraw()
188-
self.caption.set_position((0, y + pad), ha='left', va='bottom', transform=self.axes.transAxes)
187+
self.caption.set_position((0, y), ha='left', va='bottom', transform=self.axes.transAxes)
189188

190189
def _redraw_title(self):
191190
"""
@@ -227,9 +226,9 @@ def _redraw_title(self):
227226
Add some extra padding to the height.
228227
"""
229228
height = abs(caption_height) + abs(legend_height) + abs(label_height)
230-
pad_px = abs(self.axes.transAxes.transform((0, 0.05))[1] - self.axes.transAxes.transform((0, 0))[1])
229+
pad_px = abs(self.axes.transAxes.transform((0, 0.015))[1] - self.axes.transAxes.transform((0, 0))[1])
231230
pad = pad_px * 2
232-
self.axes.set_title(title, loc='left', pad=(5 + height + pad))
231+
self.axes.set_title(title, loc='left', pad=(height + pad))
233232

234233
def _get_xlabel(self, transform=None):
235234
"""

multiplex/legend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def wrapper(self, label, label_style=None, *args, **kwargs):
102102
"""
103103
offset = self._get_offset(transform=axes.transAxes)
104104
linespacing = text_util.get_linespacing(figure, axes, transform=axes.transAxes, **default_style)
105-
y = 1.05
105+
y = 1
106106
if axes.xaxis.get_label_position() == 'top':
107107
y += self.drawable._get_xlabel(transform=axes.transAxes).height * 2
108108

@@ -151,7 +151,7 @@ def redraw(self):
151151
"""
152152
Get the position at which the legend should be.
153153
"""
154-
y = 1.05
154+
y = 1
155155
if axes.xaxis.get_label_position() == 'top':
156156
y += self.drawable._get_xlabel(transform=axes.transAxes).height * 2
157157

124 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)