|
17 | 17 | import matplotlib as mpl
|
18 | 18 | import matplotlib.patches as mpatches
|
19 | 19 | import matplotlib.transforms as mtrans
|
20 |
| - |
| 20 | +import matplotlib.collections as mc |
21 | 21 |
|
22 | 22 | @image_comparison(baseline_images=['legend_auto1'], remove_text=True)
|
23 | 23 | def test_legend_auto1():
|
@@ -296,7 +296,28 @@ def test_not_covering_scatter_transform():
|
296 | 296 | plt.legend(['foo', 'bar'], loc='best')
|
297 | 297 |
|
298 | 298 |
|
| 299 | +@cleanup |
| 300 | +def test_linecollection_scaled_dashes(): |
| 301 | + lines1 = [[(0, .5), (.5, 1)], [(.3, .6), (.2, .2)]] |
| 302 | + lines2 = [[[0.7, .2], [.8, .4]], [[.5, .7], [.6, .1]]] |
| 303 | + lines3 = [[[0.6, .2], [.8, .4]], [[.5, .7], [.1, .1]]] |
| 304 | + lc1 = mc.LineCollection(lines1, linestyles="--", lw=3) |
| 305 | + lc2 = mc.LineCollection(lines2, linestyles="-.") |
| 306 | + lc3 = mc.LineCollection(lines3, linestyles=":", lw=.5) |
| 307 | + |
| 308 | + fig, ax = plt.subplots() |
| 309 | + ax.add_collection(lc1) |
| 310 | + ax.add_collection(lc2) |
| 311 | + ax.add_collection(lc3) |
| 312 | + |
| 313 | + leg = ax.legend([lc1, lc2, lc3], ["line1", "line2", 'line 3']) |
| 314 | + h1, h2, h3 = leg.legendHandles |
| 315 | + |
| 316 | + for oh, lh in zip((lc1, lc2, lc3), (h1, h2, h3)): |
| 317 | + assert oh.get_linestyles()[0][1] == lh._dashSeq |
| 318 | + assert oh.get_linestyles()[0][0] == lh._dashOffset |
| 319 | + |
| 320 | + |
299 | 321 | if __name__ == '__main__':
|
300 | 322 | import nose
|
301 | 323 | nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
|
302 |
| - |
|
0 commit comments