8000 FIX: Apply aspect before drawing starts by jklymak · Pull Request #11753 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

FIX: Apply aspect before drawing starts #11753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,23 @@ def draw(self, renderer):
if not artist.get_animated()),
key=lambda artist: artist.get_zorder())

for ax in self.axes:
locator = ax.get_axes_locator()
if locator:
pos = locator(ax, renderer)
ax.apply_aspect(pos)
else:
ax.apply_aspect()

for child in ax.get_children():
if hasattr(child, 'apply_aspect'):
locator = child.get_axes_locator()
if locator:
pos = locator(child, renderer)
child.apply_aspect(pos)
else:
child.apply_aspect()

try:
renderer.open_group('figure')
if self.get_constrained_layout() and self.axes:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions lib/matplotlib/tests/test_axes.py
6342
Original file line number Diff line number Diff line change
Expand Up @@ -5931,3 +5931,20 @@ def test_scatter_empty_data():
# making sure this does not raise an exception
plt.scatter([], [])
plt.scatter([], [], s=[], c=[])


@image_comparison(baseline_images=['annotate_across_transforms'],
style='mpl20', extensions=['png'], remove_text=True)
def test_annotate_across_transforms():
x = np.linspace(0, 10, 200)
y = np.exp(-x) * np.sin(x)

fig, ax = plt.subplots(figsize=(3.39, 3))
ax.plot(x, y)
axins = ax.inset_axes([0.4, 0.5, 0.3, 0.3])
axins.set_aspect(0.2)
axins.xaxis.set_visible(False)
axins.yaxis.set_visible(False)
ax.annotate("", xy=(x[150], y[150]), xycoords=ax.transData,
xytext=(1, 0), textcoords=axins.transAxes,
arrowprops=dict(arrowstyle="->"))
0