Title: [ENH]: provide 'last' keyword for color argument : plot(x, y, color='last') · Issue #30338 · matplotlib/matplotlib · GitHub
Open Graph Title: [ENH]: provide 'last' keyword for color argument : plot(x, y, color='last') · Issue #30338 · matplotlib/matplotlib
X Title: [ENH]: provide 'last' keyword for color argument : plot(x, y, color='last') · Issue #30338 · matplotlib/matplotlib
Description: (Not exactly a) Problem I like to plot several lines with the same color (...and different linestyle for example). It is already quite easy to write def plt_last_color() : return plt.gca().lines[-1].get_color() plt.plot(x, y1) plt.plot(x...
Open Graph Description: (Not exactly a) Problem I like to plot several lines with the same color (...and different linestyle for example). It is already quite easy to write def plt_last_color() : return plt.gca().lines[-1...
X Description: (Not exactly a) Problem I like to plot several lines with the same color (...and different linestyle for example). It is already quite easy to write def plt_last_color() : return plt.gca().lines[-1...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30338
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[ENH]: provide 'last' keyword for color argument : plot(x, y, color='last')","articleBody":"### (Not exactly a) Problem\n\nI like to plot several lines with the same color (...and different linestyle for example).\nIt is already quite easy to write \n```\ndef plt_last_color() : return plt.gca().lines[-1].get_color()\n\nplt.plot(x, y1)\nplt.plot(x, y2, lw=3, alpha=0.5, ls='dotted', color=plt_last_color())\n```\n\n### Proposition\n\nYet it would be more elegant to have this way :\n```\nplt.plot(x, y2, lw=3, alpha=0.5, ls='dotted', color='last')\n```\nThis would especially allow to have the 'last' keyword in a dictionnary, for easier management of big plots :\n```\nkw_1st = {}\nkw_2nd = {lw=3, alpha=0.5, ls='dotted', color='last'}\n\nplt.plot(x, y1, **kw_1st)\nplt.plot(x, y2, **kw_2nd)\n```\n\nProbably, there are questions to consider like in the case of multiple axes instances :\n```\nax.plot(x, y2, lw=3, alpha=0.5, ls='dotted', color='last')\n```\n-\u003e should the 'last' color be the last one plotted in the referenced `ax` of the same line (I think yes) or the last plotted color in the global plt scope...\n","author":{"url":"https://github.com/hprodh","@type":"Person","name":"hprodh"},"datePublished":"2025-07-21T19:24:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/30338/matplotlib/issues/30338"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f53ebbc4-998f-2a53-6176-a2e1e6780b4a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9F5E:10C67F:5ADD3:79EFA:6A526992 |
| html-safe-nonce | 9d2de08a5b4acc2ded9f6d01919e8a2d2076724542dbd517d387add48b6ada9d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjVFOjEwQzY3Rjo1QUREMzo3OUVGQTo2QTUyNjk5MiIsInZpc2l0b3JfaWQiOiI4MzcyMzgzODk1OTY3MTMyMDUwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 677ee76ebc2e64376ed8e600396558ff53a02c751ac8dec34fc3c1a95fb63944 |
| hovercard-subject-tag | issue:3249768642 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/30338/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dc2fc639bf0402bee72b5529ba75a79fd863ddf58ab2fe3020a779c7cd3e47d8/matplotlib/matplotlib/issues/30338 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dc2fc639bf0402bee72b5529ba75a79fd863ddf58ab2fe3020a779c7cd3e47d8/matplotlib/matplotlib/issues/30338 |
| og:image:alt | (Not exactly a) Problem I like to plot several lines with the same color (...and different linestyle for example). It is already quite easy to write def plt_last_color() : return plt.gca().lines[-1... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hprodh |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width