René's URL Explorer Experiment


Title: [Bug]: Legend kwarg `labelcolor='linecolor'` not working properly when `facecolor` is `'None'` · Issue #30298 · matplotlib/matplotlib · GitHub

Open Graph Title: [Bug]: Legend kwarg `labelcolor='linecolor'` not working properly when `facecolor` is `'None'` · Issue #30298 · matplotlib/matplotlib

X Title: [Bug]: Legend kwarg `labelcolor='linecolor'` not working properly when `facecolor` is `'None'` · Issue #30298 · matplotlib/matplotlib

Description: Bug summary The legend kwarg labelcolor='linecolor' does not play nicely with histtype='step' histograms or with fc='None' scatter plots, resulting in an invisible legend label for the histogram, and in an IndexError for the scatter plot...

Open Graph Description: Bug summary The legend kwarg labelcolor='linecolor' does not play nicely with histtype='step' histograms or with fc='None' scatter plots, resulting in an invisible legend label for the histogram, a...

X Description: Bug summary The legend kwarg labelcolor='linecolor' does not play nicely with histtype='step' histograms or with fc='None' scatter plots, resulting in an invisible legend la...

Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30298

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Legend kwarg `labelcolor='linecolor'` not working properly when `facecolor` is `'None'` ","articleBody":"### Bug summary\n\nThe legend kwarg `labelcolor='linecolor'` does not play nicely with `histtype='step'` histograms or with `fc='None'` scatter plots, resulting in an invisible legend label for the histogram, and in an IndexError for the scatter plot.\n\n### Code for reproduction\n\n```Python\nimport numpy as np\nimport matplotlib.pyplot as plt\nplt.rcParams['figure.figsize'] = (5, 5)\nplt.rcParams['legend.loc'] = 1\nplt.rcParams['legend.framealpha'] = 1\n\nx, y = np.random.randn(2, 1000)\n\nfig, axes = plt.subplots(2, 2, sharex=True, sharey='row')\naxes[0, 0].hist(x, histtype='bar', label=\"spam\")\naxes[0, 1].hist(x, histtype='step', label=\"spam\")\naxes[1, 0].scatter(x, y, label=\"spam\")\naxes[1, 1].scatter(x, y, ec='C0', fc='None', label=\"spam\")\nfor ax in axes.ravel():\n    ax.legend(labelcolor='linecolor')\n```\n\n### Actual outcome\n\n\u003cimg width=\"443\" height=\"428\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/6f528aac-fa42-456d-ad4a-4aeb3063ac62\" /\u003e\n\nNote:\n* correctly coloured legend labels in both left panels \n* invisible legend label in the top right panel\n* no legend for the bottom right panel, instead the following error message:\n\n```\n---------------------------------------------------------------------------\nIndexError                                Traceback (most recent call last)\nCell In[1], line 15\n     13 axes[1, 1].scatter(x, y, ec='C0', fc='None', label=\"spam\")\n     14 for ax in axes.ravel():\n---\u003e 15     ax.legend(labelcolor='linecolor')\n\nFile [~/.virtualenv/py3121env/lib/python3.12/site-packages/matplotlib/axes/_axes.py:337](http://localhost:8888/home/lukas/.virtualenv/py3121env/lib/python3.12/site-packages/matplotlib/axes/_axes.py#line=336), in Axes.legend(self, *args, **kwargs)\n    220 \"\"\"\n    221 Place a legend on the Axes.\n    222 \n   (...)    334 .. plot:: gallery[/text_labels_and_annotations/legend.py](http://localhost:8888/text_labels_and_annotations/legend.py)\n    335 \"\"\"\n    336 handles, labels, kwargs = mlegend._parse_legend_args([self], *args, **kwargs)\n--\u003e 337 self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)\n    338 self.legend_._remove_method = self._remove_legend\n    339 return self.legend_\n\nFile [~/.virtualenv/py3121env/lib/python3.12/site-packages/matplotlib/legend.py:601](http://localhost:8888/home/lukas/.virtualenv/py3121env/lib/python3.12/site-packages/matplotlib/legend.py#line=600), in Legend.__init__(self, parent, handles, labels, loc, numpoints, markerscale, markerfirst, reverse, scatterpoints, scatteryoffsets, prop, fontsize, labelcolor, borderpad, labelspacing, handlelength, handleheight, handletextpad, borderaxespad, columnspacing, ncols, mode, fancybox, shadow, title, title_fontsize, framealpha, edgecolor, facecolor, bbox_to_anchor, bbox_transform, frameon, handler_map, title_fontproperties, alignment, ncol, draggable)\n    597 color = getattr(handle, getter_name)()\n    598 if isinstance(color, np.ndarray):\n    599     if (\n    600             color.shape[0] == 1\n--\u003e 601             or np.isclose(color, color[0]).all()\n    602     ):\n    603         text.set_color(color[0])\n    604     else:\n\nIndexError: index 0 is out of bounds for axis 0 with size 0\n```\n\n### Expected outcome\n\nThe example plot should look like this:\n\n\u003cimg width=\"443\" height=\"428\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/ef1fd83a-51b2-4cf1-92f9-dfc6c1f1cf41\" /\u003e\n\n(I managed to create this figure by changing `labelcolor='linecolor'` to `labelcolor='C0'` in the provided example.)\n\nIn words:\n1) The legend label for the `histtype='step'` histogram (top right) should be the same as the one for the `histtype='bar'` histogram (top left).\n2) The scatter plot with empty markers (bottom right) should provide the same legend as the one with filled markers (bottom left), except that the legend handles should be obviously empty for the first and filled for the latter.\n3) There should be no error.\n\n### Additional information\n\nMight be related to #3670, #28153. \n\n### Operating system\n\nManjaro Linux\n\n### Matplotlib Version\n\n3.10.3\n\n### Matplotlib Backend\n\nmodule://matplotlib_inline.backend_inline\n\n### Python version\n\n3.12.1\n\n### Jupyter version\n\n4.4.2\n\n### Installation\n\npip","author":{"url":"https://github.com/lukashergt","@type":"Person","name":"lukashergt"},"datePublished":"2025-07-12T15:16:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/30298/matplotlib/issues/30298"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:43672155-c4da-238f-1064-02620fe9ddfd
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE960:7586F:DB5218:12AE01A:6A52187E
html-safe-noncef110983a633e5c29cb9ebdc236674aa54551964f02a227260fb78c397e8c4d0c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTYwOjc1ODZGOkRCNTIxODoxMkFFMDFBOjZBNTIxODdFIiwidmlzaXRvcl9pZCI6Ijk2Mzg2NTEwNzY3NDMwNjY4NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac17c31f5ae785e9525cda75b4d48ed9f5a9d01c8b36f8157970529525d0db957b
hovercard-subject-tagissue:3225473653
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/30298/issue_layout
twitter:imagehttps://opengraph.githubassets.com/93089cf7677dc32c02a358299252ca653891ba60408d4f0930981041f76a335a/matplotlib/matplotlib/issues/30298
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/93089cf7677dc32c02a358299252ca653891ba60408d4f0930981041f76a335a/matplotlib/matplotlib/issues/30298
og:image:altBug summary The legend kwarg labelcolor='linecolor' does not play nicely with histtype='step' histograms or with fc='None' scatter plots, resulting in an invisible legend label for the histogram, a...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamelukashergt
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
turbo-cache-controlno-preview
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
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7aed05249554b889eb33d002851a973eebcc7e91
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/issues/30298#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F30298
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%2Fissues%2F30298
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%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=matplotlib%2Fmatplotlib
Reloadhttps://github.com/matplotlib/matplotlib/issues/30298
Reloadhttps://github.com/matplotlib/matplotlib/issues/30298
Reloadhttps://github.com/matplotlib/matplotlib/issues/30298
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/30298
matplotlib https://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/30298
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
#30328https://github.com/matplotlib/matplotlib/pull/30328
[Bug]: Legend kwarg labelcolor='linecolor' not working properly when facecolor is 'None' https://github.com/matplotlib/matplotlib/issues/30298#top
#30328https://github.com/matplotlib/matplotlib/pull/30328
v3.11.0https://github.com/matplotlib/matplotlib/milestone/96
https://github.com/lukashergt
lukashergthttps://github.com/lukashergt
on Jul 12, 2025https://github.com/matplotlib/matplotlib/issues/30298#issue-3225473653
https://private-user-images.githubusercontent.com/18258042/465630454-6f528aac-fa42-456d-ad4a-4aeb3063ac62.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODM3NjU0MTgsIm5iZiI6MTc4Mzc2NTExOCwicGF0aCI6Ii8xODI1ODA0Mi80NjU2MzA0NTQtNmY1MjhhYWMtZmE0Mi00NTZkLWFkNGEtNGFlYjMwNjNhYzYyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITU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ZDI5ZDUwNmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.vL59_XZF1kmfK2IVrsNe6RZed_ipaNZ4OK_ZB1DfgKs
#3670https://github.com/matplotlib/matplotlib/issues/3670
#28153https://github.com/matplotlib/matplotlib/issues/28153
v3.11.0https://github.com/matplotlib/matplotlib/milestone/96
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.