Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8833778

Browse files
author
simonpf
committed
Added image test for capstyle and joinstyle of Collection class
1 parent e56e3ba commit 8833778

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

29.7 KB
Loading

lib/matplotlib/tests/test_collections.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import matplotlib.pyplot as plt
1515
import matplotlib.collections as mcollections
1616
import matplotlib.transforms as mtransforms
17-
from matplotlib.collections import Collection, EventCollection
17+
from matplotlib.collections import Collection, LineCollection, EventCollection
1818
from matplotlib.testing.decorators import image_comparison
1919

2020

@@ -642,6 +642,28 @@ def test_joinstyle():
642642
assert_equal(col.get_joinstyle(), 'miter')
643643

644644

645+
@image_comparison(baseline_images=['cap_and_joinstyle'],
646+
extensions=['png'])
647+
def test_cap_and_joinstyle_image():
648+
fig = plt.figure()
649+
ax = fig.add_subplot(1, 1, 1)
650+
ax.set_xlim([-0.5, 1.5])
651+
ax.set_ylim([-0.5, 2.5])
652+
653+
x = np.array([0.0, 1.0, 0.5])
654+
ys = np.array([[0.0], [0.5], [1.0]]) + np.array([[0.0, 0.0, 1.0]])
655+
656+
segs = np.zeros((3, 3, 2))
657+
segs[:, :, 0] = x
658+
segs[:, :, 1] = ys
659+
line_segments = LineCollection(segs, linewidth=[10, 15, 20])
660+
line_segments.set_capstyle("round")
661+
line_segments.set_joinstyle("miter")
662+
663+
ax.add_collection(line_segments)
664+
ax.set_title('Line collection with customized caps and joinstyle')
665+
666+
645667
@image_comparison(baseline_images=['scatter_post_alpha'],
646668
extensions=['png'], remove_text=True,
647669
style='default')

0 commit comments

Comments
 (0)