Skip to content

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Mar 28, 2018

PR Summary

As per #10844, it was not possible to properly use text.OffsetFrom if the artist was a legend. The issue was that legend.get_window_extent was calling the wrong patch object to get the patch location.

The following code now returns properly placed text regardless of the savefig dpi:

import matplotlib.pyplot as plt
import matplotlib.text

fig, ax = plt.subplots(dpi=200, figsize=(3,3))
ax.plot(range(10), label='Bah')
ax.set_xticks([])
ax.set_yticks([])
legend = ax.legend(loc="upper right")

offset = matplotlib.text.OffsetFrom(legend, (1.0, 0.0))
ax.annotate("info_string", xy=(0,0),size=14,
            xycoords='figure fraction', xytext=(0, 0), textcoords=offset,
            horizontalalignment='right', verticalalignment='top')
fig.savefig('plot1.png', dpi=100)

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant

@jklymak jklymak added this to the v3.0 milestone Mar 28, 2018
@jklymak jklymak force-pushed the fix-proper-legend-window-extent branch from 3b27337 to 9a03a2d Compare March 28, 2018 20:36
@jklymak
Copy link
Member Author

jklymak commented Apr 1, 2018

Bump - this is a pretty straightforward one that fixes at least one reported issue

@phobson phobson merged commit 9b15a52 into matplotlib:master Apr 8, 2018
@jklymak
Copy link
Member Author

jklymak commented Apr 8, 2018

Thanks @phobson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy