[WiP] ENH: Add a “loose” version of the dashed line styles #8048
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andlines.dotted@loose_pattern
. Currently, they are similar to the rcParamslines.dashed_pattern
,lines.dashdot_pattern
andlines.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
Line2D
docstring inmatplotlib.lines
test_linestyle_variants
intests/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)Example
A small example of what it does currently looks like:
Script source:
Edit: typo…