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

Skip to content

Commit 766efaa

Browse files
leejjoonJulian Mehne
authored andcommitted
fix legend_handler.HandlerNpoints.get_xdata of wrong xdescent interpretation.
1 parent 2b97396 commit 766efaa

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

lib/matplotlib/legend_handler.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,14 @@ def get_xdata(self, legend, xdescent, ydescent, width, height, fontsize):
150150
if numpoints > 1:
151151
# we put some pad here to compensate the size of the
152152
# marker
153-
xdata = np.linspace(-xdescent + self._marker_pad * fontsize,
154-
width - self._marker_pad * fontsize,
153+
pad = self._marker_pad * fontsize
154+
xdata = np.linspace(-xdescent + pad,
155+
-xdescent + width - pad,
155156
numpoints)
156157
xdata_marker = xdata
157158
elif numpoints == 1:
158-
xdata = np.linspace(-xdescent, width, 2)
159-
xdata_marker = [0.5 * width - 0.5 * xdescent]
159+
xdata = np.linspace(-xdescent, -xdescent+width, 2)
160+
xdata_marker = [-xdescent + 0.5 * width]
160161

161162
return xdata, xdata_marker
162163

0 commit comments

Comments
 (0)