On Wed, Aug 30, 2017 at 12:21 PM, Jody Klymak ***@***.***> wrote:
Bug report
The bbox returned by axes.get_tightbbox doesn't include legends that
overspill the axis.
*Bug summary*
This is an easy fix, but wasn't sure if the behavior was desired:
*Code for reproduction*
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
h = ax.plot(range(10), label='boo')print(ax.get_tightbbox(fig.canvas.get_renderer()))
hh = ax.legend(h, 'Boooo', loc='center left', bbox_to_anchor=(1., 0.5))print(ax.get_tightbbox(fig.canvas.get_renderer()))print(hh._legend_box.get_window_extent(renderer))
*Actual outcome*
Bbox(x0=61.40277777777777, y0=29.077777777777776, x1=579.5, y1=425.9)
Bbox(x0=61.40277777777777, y0=29.077777777777776, x1=579.5, y1=425.9)
Bbox(x0=540.288888888889, y0=212.48888888888885, x1=659.413888888889, y1=262.71111111111105)
*Expected outcome*
The second bbox could have x1=659.41 to include the legend.
** solution **
in axes/_bases.py we could change:
for child in self.get_children():
if isinstance(child, OffsetBox) and child.get_visible():
bb.append(child.get_window_extent(renderer))
elif isinstance(child, Legend) and child.get_visible():
bb.append(child._legend_box.get_window_extent(renderer))
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9130>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-NnT0L6XDAF3Ks8Zj2IqgVxdroQWks5sdYv5gaJpZM4PHo9e>
.
@WeatherGod This is just designed to catch legends that are children of the axes object. This won't do anything with legends that are associated w/ figures.
Activity
WeatherGod commented on Aug 30, 2017
jklymak commented on Aug 30, 2017
@WeatherGod This is just designed to catch legends that are children of the axes object. This won't do anything with legends that are associated w/ figures.
jklymak commented on Nov 26, 2017
Closed by #9164