-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ENH: enable stripey lines #23208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: enable stripey lines #23208
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Striped lines (experimental) | ||
---------------------------- | ||
|
||
New *gapcolor* parameter enables the creation of striped lines. | ||
|
||
.. plot:: | ||
:include-source: true | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
x = np.linspace(1., 3., 10) | ||
y = x**3 | ||
|
||
fig, ax = plt.subplots() | ||
ax.plot(x, y, linestyle='--', color='orange', gapcolor='blue', | ||
linewidth=3, label='a striped line') | ||
ax.legend() | ||
plt.show() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -304,6 +304,17 @@ def test_marker_as_markerstyle(): | |
assert_array_equal(line3.get_marker().vertices, triangle1.vertices) | ||
|
||
|
||
@image_comparison(['striped_line.png'], remove_text=True, style='mpl20') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interestingly, Still, I propose not to pick up text in the reference image. Do you want the legend entries as a test that the lines are drawn correctly there? If not remove the legend, if yes use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @oscargus asked for the legend so I guess he wanted to check the legend lines are drawn correctly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct! Completely happy without text! |
||
def test_striped_lines(): | ||
rng = np.random.default_rng(19680801) | ||
_, ax = plt.subplots() | ||
ax.plot(rng.uniform(size=12), color='orange', gapcolor='blue', | ||
linestyle='--', lw=5, label=' ') | ||
ax.plot(rng.uniform(size=12), color='red', gapcolor='black', | ||
linestyle=(0, (2, 5, 4, 2)), lw=5, label=' ', alpha=0.5) | ||
ax.legend(handlelength=5) | ||
|
||
|
||
@check_figures_equal() | ||
def test_odd_dashes(fig_test, fig_ref): | ||
fig_test.add_subplot().plot([1, 2], dashes=[1, 2, 3]) | ||
|
Uh oh!
There was an error while loading. Please reload this page.