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

Skip to content

Commit 332de56

Browse files
author
Francis Colas
committed
added test image and entry in whats_new
1 parent ba18dc1 commit 332de56

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

doc/users/whats_new.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ polar-plot r-tick locations
280280
Added the ability to control the angular position of the r-tick labels
281281
on a polar plot via :func:`~matplotlib.Axes.axes.set_rlabel_position`.
282282

283+
Support for legend for PolyCollection and stackplot
284+
```````````````````````````````````````````````````
285+
Added a `legend_handler` for :class:`~matplotlib.collections.PolyCollection` as well as a `labels` argument to
286+
:func:`~matplotlib.axes.Axes.stackplot`.
287+
288+
283289
Date handling
284290
-------------
285291

lib/matplotlib/tests/test_legend.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,22 @@ def test_legend_handler_map(self):
218218
handles_labels.assert_called_with({'1': 2})
219219

220220

221+
@image_comparison(baseline_images=['legend_stackplot'], extensions=['png'])
222+
def test_legend_stackplot():
223+
'''test legend for PolyCollection using stackplot'''
224+
# related to #1341, #1943, and PR #3303
225+
fig = plt.figure()
226+
ax = fig.add_subplot(111)
227+
x = np.linspace(0, 10, 10)
228+
y1 = 1.0 * x
229+
y2 = 2.0 * x + 1
230+
y3 = 3.0 * x + 2
231+
ax.stackplot(x, y1, y2, y3, labels=['y1', 'y2', 'y3'])
232+
ax.set_xlim((0, 10))
233+
ax.set_ylim((0, 70))
234+
ax.legend(loc=0)
235+
236+
221237
if __name__ == '__main__':
222238
import nose
223239
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)