Title: [WiP] ENH: Add a “loose” version of the dashed line styles by afvincent · Pull Request #8048 · matplotlib/matplotlib · GitHub
Open Graph Title: [WiP] ENH: Add a “loose” version of the dashed line styles by afvincent · Pull Request #8048 · matplotlib/matplotlib
X Title: [WiP] ENH: Add a “loose” version of the dashed line styles by afvincent · Pull Request #8048 · matplotlib/matplotlib
Description: Rationale Several tickets pointed out that the defaults dashed line styles have a “frequency” that is too high (#7991), especially when using a “dotted” style for grid lines (#6515). This PR aims at introducing a “loose” version of these dashed line styles, in the spirit of what had been suggested in #7087 . Coupled to sane defaults (still to be found/discussed), “casual users” (or myself :) ) could have access in an easy fashion to “less frequently” dashed lines. And “power-users” could even tweak these additional dash patterns in their matplotlibrc file to get a fast & easy access to supplementary dash patterns. PS: not sure if it belong to the “API Changes” flag, so feel free to remove if it does not… Implementation Three new rcParams are added: lines.dashed@loose_pattern, lines.dashdot@loose_pattern and lines.dotted@loose_pattern. Currently, they are similar to the rcParams lines.dashed_pattern, lines.dashdot_pattern and lines.dotted_pattern but with off inks parts that have been tripled in length. This specific value can of course be discussed. One can now use these three new line styles by adding “@Loose” after the line style “ID string”. Here is for example the case for loosely dotted lines: ax.plot(…, linestyle="dotted@loose") ax.plot(…, linestyle=":@loose") ax.plot(…, ":@looseob") # MATLAB-style (yes, it starts to become verbose/hard to read…) Feel free to suggest anything better than using the suffix “@Loose” to specify that one wants a loosely dashed line style. Still to be done update the Line2D docstring in matplotlib.lines update the test test_linestyle_variants in tests/test_lines.py (I do not really understand how this test works: it looks like an image test but does not have the @image_comparison decorator) show this new functionality somewhere in the documentation optional (could be done in a further PR): add a new line style variant “dashdotdot”/“-..” (and its “loose” variant) Example A small example of what it does currently looks like: PDF: Testing_named_line_styles.pdf PNG (100 DPI): Script source: import matplotlib.pyplot as plt fig, ax = plt.subplots(num="Testing named line styles", figsize=(9.6, 6.4)) for ii, ls in enumerate(['-', 'solid', '--', 'dashed', '-.', 'dashdot', ':', 'dotted', '--@loose', 'dashed@loose', '-.@loose', 'dashdot@loose', ':@loose', 'dotted@loose' ]): ax.plot([ii, ii + 1], linestyle=ls, color='tab:red' if 'loose' in ls else 'tab:blue', label=ls) # MATLAB-like all in one line style if any(special_char in ls for special_char in ('-', '.', ':')): allinone_ls = ls + ">k" ax.plot([-ii//2, -(ii//2 + 1)], allinone_ls, label=allinone_ls) ax.legend(loc='lower center', bbox_to_anchor=(0.5, 1.02), ncol=7, columnspacing=1) fig.subplots_adjust(top=0.85) # make space for top legend for ext, dpi in (('.png', 100), ('.pdf', None)): fig.savefig(fig.get_label().replace(" ", "_") + ext, dpi=dpi) Edit: typo…
Open Graph Description: Rationale Several tickets pointed out that the defaults dashed line styles have a “frequency” that is too high (#7991), especially when using a “dotted” style for grid lines (#6515). This PR aims a...
X Description: Rationale Several tickets pointed out that the defaults dashed line styles have a “frequency” that is too high (#7991), especially when using a “dotted” style for grid lines (#6515). This PR aims a...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/8048
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:f5c0cd54-d309-afef-6de4-4296f294b2a0 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 962A:2345DC:5F80F6:8B0BFA:6A54A377 |
| html-safe-nonce | 10311d204f8f74d10a4e6923b3e65df3027b791b1a5c623e6950cdc865ad7bd7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjJBOjIzNDVEQzo1RjgwRjY6OEIwQkZBOjZBNTRBMzc3IiwidmlzaXRvcl9pZCI6IjM1NDY3MTE5MDgwODk2MzU3MDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2370c4f8931072d35f23cdb8fc6e7c0f712ac5571c4b52bf2fead54d6be74ad5 |
| hovercard-subject-tag | pull_request:105246915 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/matplotlib/matplotlib/pull/8048/files |
| twitter:image | https://avatars.githubusercontent.com/u/17270724?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/17270724?s=400&v=4 |
| og:image:alt | Rationale Several tickets pointed out that the defaults dashed line styles have a “frequency” that is too high (#7991), especially when using a “dotted” style for grid lines (#6515). This PR aims a... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f8cfff6384f62259baea531c7f58bc7040f8dd92 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width