René's URL Explorer Experiment


Title: Add legend handler and artist for FancyArrow by magedhennawy · Pull Request #10688 · matplotlib/matplotlib · GitHub

Open Graph Title: Add legend handler and artist for FancyArrow by magedhennawy · Pull Request #10688 · matplotlib/matplotlib

X Title: Add legend handler and artist for FancyArrow by magedhennawy · Pull Request #10688 · matplotlib/matplotlib

Description: closes #8236 I added new legend handlers for FancyArrowPatch, Annotation artists and HandlerAnnotation. HandlerAnnotation can draw FancyArrowPatch artist in the legend: if the annotation has an arrow, it uses HandlerFancyArrowPatch to draw an arrow Example code: import matplotlib.pylab as plt from matplotlib.patches import FancyArrowPatch from matplotlib.legend_handler import HandlerAnnotation fig, ax = plt.subplots(1) ax.plot([0, 1], [0, 0], label='line1') ax.plot([0, 1], [1, 1], label='line2') ax.annotate("", xy=(0.3,1.0), xytext=(0.3,0.0), arrowprops={'arrowstyle':'<->', 'color':'C7' }, label='distance') ax.legend() plt.show() **************** Added extra features. ****************** after merge with #8292 I added new legend handlers for Text, FancyArrowPatch and Annotation artists (HandlerText, HandlerFancyArrowPatch and HandlerAnnotation). HandlerAnnotation can draw different artists in the legend: if the annotation has no text and no arrow, it draws a white Rectangle if the annotation has only text, it uses HandlerText to draw a text. The text is replaced by 'Aa' if it is longer than one character. (This is configurable by setting rep_str and rep_maxlen.) if the annotation has only an arrow, it uses HandlerFancyArrowPatch to draw an arrow If the annotation has both text and arrow, it uses HandlerTuple to draw both. In HandlerTuple, I added the possibility of different width ratios for the artists. HandlerAnnotation uses a width_ratios=[1,4] (ie. the arrow is 4 times wider than the text). Example code: import matplotlib.pylab as plt from matplotlib.patches import FancyArrowPatch from matplotlib.legend_handler import HandlerAnnotation fig, ax = plt.subplots(1) ax.plot([0, 1], [0, 0], label='line1') ax.plot([0, 1], [1, 1], label='line2') # no text, no arrow ax.annotate("", xy=(0.1,0.5), xytext=(0.1,0.5), label='annotation (empty)') # text, no arrow my_annotation = ax.annotate("X", xy=(0.1,0.5), xytext=(0.1,0.5), color='C2', label='annotation (text, no arrow)') # no text, arrow ax.annotate("", xy=(0.3,1.0), xytext=(0.3,0.0), arrowprops={'arrowstyle':'<->', 'color':'C7' }, label='annotation (no text, arrow)') # text, arrow ax.annotate("Some long string", xy=(0.4,1.0), xytext=(0.35,0.1), arrowprops={'arrowstyle':'->', 'color':'C2' }, color='C1', label='annotation (text + arrow)') # Fancy arrow patch arrpatch = FancyArrowPatch([0.5, 0.8], [0.9, 0.9], arrowstyle='<|-', mutation_scale=20, color='C3', label='arrowpatch') ax.add_patch(arrpatch) # Long text, will not be used in legend ax.text(x=0.1, y=0.1, s='Hello', color='C5', label='text') # Short text, copied in legend ax.text(x=0.1, y=0.2, s='Z', color='C0', label='short text') ax.legend(handler_map={my_annotation: HandlerAnnotation(rep_str='Abcde', rep_maxlen=0)}) fig.show()

Open Graph Description: closes #8236 I added new legend handlers for FancyArrowPatch, Annotation artists and HandlerAnnotation. HandlerAnnotation can draw FancyArrowPatch artist in the legend: if the annotation has an arr...

X Description: closes #8236 I added new legend handlers for FancyArrowPatch, Annotation artists and HandlerAnnotation. HandlerAnnotation can draw FancyArrowPatch artist in the legend: if the annotation has an arr...

Opengraph URL: https://github.com/matplotlib/matplotlib/pull/10688

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:6b62acc6-bd4b-be75-d361-b31ffe7a0ad3
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idAA78:19F60D:151260D:1BD0405:6A51BDA9
html-safe-nonce97301c354a3bc640ef851bb8101527fe0f5c95abffb9f4564da5a56faff6117d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTc4OjE5RjYwRDoxNTEyNjBEOjFCRDA0MDU6NkE1MUJEQTkiLCJ2aXNpdG9yX2lkIjoiMzU2OTkxNzkzNDIxNzMxMzcwNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacf44a6298089514b3eb5b06c655f35fc5a759f69f567accdfbdf5cc3f406acd59
hovercard-subject-tagpull_request:172980958
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/10688/files
twitter:imagehttps://avatars.githubusercontent.com/u/14252814?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/14252814?s=400&v=4
og:image:altcloses #8236 I added new legend handlers for FancyArrowPatch, Annotation artists and HandlerAnnotation. HandlerAnnotation can draw FancyArrowPatch artist in the legend: if the annotation has an arr...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git
octolytics-dimension-user_id215947
octolytics-dimension-user_loginmatplotlib
octolytics-dimension-repository_id1385122
octolytics-dimension-repository_nwomatplotlib/matplotlib
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1385122
octolytics-dimension-repository_network_root_nwomatplotlib/matplotlib
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7aed05249554b889eb33d002851a973eebcc7e91
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/pull/10688/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fpull%2F10688%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fpull%2F10688%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=matplotlib%2Fmatplotlib
Reloadhttps://github.com/matplotlib/matplotlib/pull/10688/files
Reloadhttps://github.com/matplotlib/matplotlib/pull/10688/files
Reloadhttps://github.com/matplotlib/matplotlib/pull/10688/files
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/10688/files
matplotlib https://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/10688/files
Notifications https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Fork 8.4k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Star 23k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Code https://github.com/matplotlib/matplotlib
Issues 1.1k https://github.com/matplotlib/matplotlib/issues
Pull requests 409 https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality 0 https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
Code https://github.com/matplotlib/matplotlib
Issues https://github.com/matplotlib/matplotlib/issues
Pull requests https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fmatplotlib%2Fmatplotlib%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib%2Fissues%2Fnew%2Fchoose
magedhennawyhttps://github.com/magedhennawy
matplotlib:masterhttps://github.com/matplotlib/matplotlib/tree/master
magedhennawy:issue-8236-devhttps://github.com/magedhennawy/matplotlib/tree/issue-8236-dev
Conversation 67 https://github.com/matplotlib/matplotlib/pull/10688
Commits 2 https://github.com/matplotlib/matplotlib/pull/10688/commits
Checks 0 https://github.com/matplotlib/matplotlib/pull/10688/checks
Files changed https://github.com/matplotlib/matplotlib/pull/10688/files
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/10688/files
Add legend handler and artist for FancyArrow https://github.com/matplotlib/matplotlib/pull/10688/files#top
Show all changes 2 commits https://github.com/matplotlib/matplotlib/pull/10688/files
4c2e1d6 Add legend handler and artist for FancyArrow (clean commit) Mar 19, 2018 https://github.com/matplotlib/matplotlib/pull/10688/commits/4c2e1d6657a5fffff24d1ffdf2ed3396d35f21c6
6cf5e2b DOC: add whats_new entry tacaswell Jul 9, 2018 https://github.com/matplotlib/matplotlib/pull/10688/commits/6cf5e2bd80bc696d2bd8b2ad6e5bee0cf5bdb3a3
Clear filters https://github.com/matplotlib/matplotlib/pull/10688/files
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/10688/files
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/10688/files
more_legend_handlers.rst https://github.com/matplotlib/matplotlib/pull/10688/files#diff-866b67cac4dd81094d4ef063dd07183cf3852353f3efc3e05ddcbac6ef92d5fa
legend.py https://github.com/matplotlib/matplotlib/pull/10688/files#diff-e7a00bb4a353fa623c1d0c1de5c6ca602b7ab38e8906d4842640983133b9196a
legend_handler.py https://github.com/matplotlib/matplotlib/pull/10688/files#diff-bf161cdba7927d70f74280599f230645a986d47e57821a961a2dd768dc403a05
legend_all_annotation_text.png https://github.com/matplotlib/matplotlib/pull/10688/files#diff-9a422cc8441660221a0316388bf3e34694748f0f105df6814a1cfb25f14ee177
test_legend.py https://github.com/matplotlib/matplotlib/pull/10688/files#diff-1b573023d84935306a147bec7f137e59ae79c3d4f3bbea81152eb0c94b58a579
doc/users/next_whats_new/more_legend_handlers.rsthttps://github.com/matplotlib/matplotlib/pull/10688/files#diff-866b67cac4dd81094d4ef063dd07183cf3852353f3efc3e05ddcbac6ef92d5fa
View file https://github.com/magedhennawy/matplotlib/blob/6cf5e2bd80bc696d2bd8b2ad6e5bee0cf5bdb3a3/doc/users/next_whats_new/more_legend_handlers.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/matplotlib/matplotlib/pull/10688/{{ revealButtonHref }}
lib/matplotlib/legend.pyhttps://github.com/matplotlib/matplotlib/pull/10688/files#diff-e7a00bb4a353fa623c1d0c1de5c6ca602b7ab38e8906d4842640983133b9196a
View file https://github.com/magedhennawy/matplotlib/blob/6cf5e2bd80bc696d2bd8b2ad6e5bee0cf5bdb3a3/lib/matplotlib/legend.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/matplotlib/matplotlib/pull/10688/{{ revealButtonHref }}
https://github.com/matplotlib/matplotlib/pull/10688/files#diff-e7a00bb4a353fa623c1d0c1de5c6ca602b7ab38e8906d4842640983133b9196a
https://github.com/matplotlib/matplotlib/pull/10688/files#diff-e7a00bb4a353fa623c1d0c1de5c6ca602b7ab38e8906d4842640983133b9196a
https://github.com/matplotlib/matplotlib/pull/10688/files#diff-e7a00bb4a353fa623c1d0c1de5c6ca602b7ab38e8906d4842640983133b9196a
https://github.com/matplotlib/matplotlib/pull/10688/files#diff-e7a00bb4a353fa623c1d0c1de5c6ca602b7ab38e8906d4842640983133b9196a
https://github.com/matplotlib/matplotlib/pull/10688/files#diff-e7a00bb4a353fa623c1d0c1de5c6ca602b7ab38e8906d4842640983133b9196a
https://github.com/matplotlib/matplotlib/pull/10688/files#diff-e7a00bb4a353fa623c1d0c1de5c6ca602b7ab38e8906d4842640983133b9196a
https://github.com/matplotlib/matplotlib/pull/10688/files#diff-e7a00bb4a353fa623c1d0c1de5c6ca602b7ab38e8906d4842640983133b9196a
https://github.com/matplotlib/matplotlib/pull/10688/files#diff-e7a00bb4a353fa623c1d0c1de5c6ca602b7ab38e8906d4842640983133b9196a
https://github.com/matplotlib/matplotlib/pull/10688/files#diff-e7a00bb4a353fa623c1d0c1de5c6ca602b7ab38e8906d4842640983133b9196a
https://github.com/matplotlib/matplotlib/pull/10688/files#diff-e7a00bb4a353fa623c1d0c1de5c6ca602b7ab38e8906d4842640983133b9196a
https://github.com/matplotlib/matplotlib/pull/10688/files#diff-e7a00bb4a353fa623c1d0c1de5c6ca602b7ab38e8906d4842640983133b9196a
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/10688/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.