Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add new plot style: stackplot #819

Closed
wants to merge 13 commits into from

5 participants

Damon McDougall Piti Ongmongkolkul Michael Droettboom Benjamin Root Phil Elson
Damon McDougall
Collaborator

This addresses issue #359.

There is also an example so you can try out the pull request. Sample output from this code is provided below:

stackplot

Feedback is greatly appreciated, as always.

Damon McDougall
Collaborator

Hooray, only two commits this time!

Piti Ongmongkolkul

+1

Michael Droettboom mdboom commented on the diff
lib/matplotlib/stackplot.py
((6 lines not shown))
+(http://stackoverflow.com/users/66549/doug)
+
+"""
+import numpy as np
+import matplotlib
+
+__all__ = ['stackplot']
+
+
+def stackplot(axes, x, y):
+ """Draws a stacked area plot.
+
+ Parameters
+ ----------
+ *x* : 1d array of dimension N
+ *y* : 2d array of dimension MxN
Michael Droettboom Owner
mdboom added a note

We should probably clarify here what's in the comment below: that the data is not "pre-stacked".

It might also be nice for y to be either a 2d array of MxN, or a variable number of y arguments (which would be stacked implicitly here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/matplotlib/stackplot.py
((26 lines not shown))
+ element in the stacked area plot.
+ """
+
+ y = np.atleast_2d(y)
+
+ # Assume data passed has not been 'stacked', so stack it here.
+ y_stack = np.cumsum(y, axis=0)
+
+ r = []
+
+ # Color between x = 0 and the first array.
+ r.append(axes.fill_between(x, 0, y_stack[0,:], facecolor=axes._get_lines.color_cycle.next()))
+
+ # Color between array i-1 and array i
+ for i in xrange(len(y)-1):
+ r.append(axes.fill_between(x, y_stack[i-1,:], y_stack[i,:], facecolor=axes._get_lines.color_cycle.next()))
Michael Droettboom Owner
mdboom added a note

A nice bonus might be the ability to pass in a kwarg with a list of colors if the user wants to override the color defaults.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Michael Droettboom
Owner

This is great! Barring my minor comments, I think this is good to go. (And I think the color thing could be done as a second step if necessary -- my other comments are more important, IMHO).

Damon McDougall
Collaborator

Thanks for your feedback @mdboom. GitHub is great for code review and feedback. I love it.

None of these most recent commits include the colors keyword argument functionality you mentioned. I figured I could do that at a later time.

Michael Droettboom
Owner

I think this is ready to merge. Will leave it up for a few more days in case others would like to comment.

Benjamin Root
Collaborator

pyplot.py needs update, as well as some docs (front page, what's new and API changes). I haven't looked over the docstrings yet.

Damon McDougall
Collaborator

I've been trying to figure out what @WeatherGod means by 'pyplot.py needs an update'. I think I figured it out.

I add stackplot to the _plot_commands variable and run boilerplate.py. Then I tested the stackplot function using pylab. I get the following error:

'NoneType' object has no attribute 'pop'.

I then spent an hour trying figure out what was going wrong. Long story short:

1) stackplot has no argument **kwargs;
2) as a result, boilerplate.py adds the line: hold = None.pop('hold', None) to the stackplot method in pyplot.py.

How should I deal with this? Deleting it manually is not a solution because any time anybody else runs boilerplate the same thing will happen. Maybe I should just add a **kwargs argument and pass them to all the called Axes.fill_between methods in stackplot. The bonus there is that stackplot would then support things like alpha, linewidth and facecolor. Also, I plan to add support for custom coloring, so it will inevitably be added in the future.

Michael Droettboom
Owner

This perhaps should be re-evaluated in relation to the related PR #847.

The example should be converted into a unit test.

Other than that, this looks generally good to me.

Benjamin Root
Collaborator

It does appear to need a rebase at the very least. Most likely due to changes in pyplot.py?

Damon McDougall
Collaborator

You mean you want me to rebase against current master? I can do that. Are there any changes you wish me to make before I rebase?

Benjamin Root
Collaborator

Changes before rebasing would only complicate things. There still remains discussion regarding design decisions, but at least we would have a working branch to refer to in this manner.

Damon McDougall
Collaborator

I've rebased against master.

Phil Elson
Collaborator

@dmcdougall: Unfortunately this will need rebasing again due to some changes to the boilerplate script. It is possible that you will get conflicts there and in the actual pyplot file. The good news is that you can now simply run boilerplate.py and it automatically updates pyplot for you.

Once you have done that, and added the example code as a simple unit test, I will merge the PR. Great work!

dmcdougall added some commits
Damon McDougall dmcdougall Added new plot style: stackplot.
Stackplot adds the feature request in issue #359
(matplotlib#359) and borrows
heavily from Doug Y'barbo's stackoverflow answer
(http://stackoverflow.com/questions/2225995/how-can-i-create-stacked-line-graph-with-matplotlib).
914385a
Damon McDougall dmcdougall Added stackplot example. 4557573
Damon McDougall dmcdougall Make docstring more helpful.
The data *y* is assumed to be unstacked. This is now explicitly said in
the docstring for the paramater *y*.
ff8ecde
Damon McDougall dmcdougall Make stackplot take an arbitrary number of args.
stackplot now supports taking either an MxN array of data, stacking
along axis=0, or an arbitrary number of 1xN arrays, stacking them in the
order passed.

No checks are done for the case when no the number of args is zero. An
exception should probably be raised here.

Updated docstring to explain new call signatures.
8bbac65
Damon McDougall dmcdougall Updated stackplot example.
Stackplot example now reflects usage of variadic calling signature.
6674548
Damon McDougall dmcdougall Update changelog to include stackplot. 3e8fe6e
Damon McDougall dmcdougall Stackplot now supports the same keyword aargs as matplotlib.Axes.fill…
…_between().

This is a measure to make boilerplate.py not produce a pyplot.py file
with syntax errors. It's also a sensible course of action considering
new stackplot features will almost certainly require keyword arguments
anyway.
38a903f
Damon McDougall dmcdougall Fixed an issue where stackplot didn't fill stacked data in correct or…
…der.
91a233a
Damon McDougall dmcdougall Added stackplot to list of pyplot commands.
pyplot.py now contains the necessary information to make stackplot work
inside of pyplot.
7b93874
Damon McDougall dmcdougall Added support for custom colour cycle.
New keyword argument 'colors' can be passed to allow custom colouring of
the stacked areas in a stacked area plot.
a66ca21
Damon McDougall dmcdougall Add stackplot to list of plotting commands. a3a35fb
Damon McDougall
Collaborator

@pelson Thanks for the feedback. I've rebased and saw a conflict in boilerplate.py. I fixed everything. I'm currently at a conference stuck behind a router that blocks all ports except 80 and 443. I will push the changes as soon as I am behind a reasonable router.

Damon McDougall
Collaborator

Aha! I ninja pushed through a proxy. All sorted now!

Phil Elson pelson was assigned
Phil Elson
Collaborator

@dmcdougall: Ideally, I would just like to get a unittest added and then I can press the big green merge button ;-)

Damon McDougall dmcdougall Added stackplot unit test.
Test images added. Unit test writted and unit test added to default
tests in __init__.py
0fd841c
Damon McDougall
Collaborator

Done. Let me know if I messed anything up. I followed the guidelines here.

Thanks.

Phil Elson
Collaborator

Don't think you need the stackplot_test_image_pdf.png file.

Damon McDougall
Collaborator

I have no idea why that was there; the test produced it. Maybe because I am using the pdf backend by default? Anyway, it's gone.

Phil Elson
Collaborator

So the tests, by default, produce a png, a svg and a pdf, but in order to do the test comparison they are rasterised into <fname>_svg.png and <fname>_pdf.png, the latter two don't need to be in the baseline directory. Will merge in 24 hrs.

Phil Elson pelson referenced this pull request from a commit in pelson/matplotlib
Phil Elson pelson Merged #819: dmcdougall's stackplot 5675ffa
Phil Elson
Collaborator

I merged this manually to mpl. I moved your test into the test_axes module and squashed the commits into one (see 5675ffa).

Thanks for all your work (and patience) on this PR.

Phil Elson pelson closed this
Phil Elson pelson referenced this pull request
Closed

new plot style: stackplot #359

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 19, 2012
  1. Damon McDougall

    Added new plot style: stackplot.

    dmcdougall authored
    Stackplot adds the feature request in issue #359
    (matplotlib#359) and borrows
    heavily from Doug Y'barbo's stackoverflow answer
    (http://stackoverflow.com/questions/2225995/how-can-i-create-stacked-line-graph-with-matplotlib).
  2. Damon McDougall

    Added stackplot example.

    dmcdougall authored
  3. Damon McDougall

    Make docstring more helpful.

    dmcdougall authored
    The data *y* is assumed to be unstacked. This is now explicitly said in
    the docstring for the paramater *y*.
  4. Damon McDougall

    Make stackplot take an arbitrary number of args.

    dmcdougall authored
    stackplot now supports taking either an MxN array of data, stacking
    along axis=0, or an arbitrary number of 1xN arrays, stacking them in the
    order passed.
    
    No checks are done for the case when no the number of args is zero. An
    exception should probably be raised here.
    
    Updated docstring to explain new call signatures.
  5. Damon McDougall

    Updated stackplot example.

    dmcdougall authored
    Stackplot example now reflects usage of variadic calling signature.
  6. Damon McDougall
  7. Damon McDougall

    Stackplot now supports the same keyword aargs as matplotlib.Axes.fill…

    dmcdougall authored
    …_between().
    
    This is a measure to make boilerplate.py not produce a pyplot.py file
    with syntax errors. It's also a sensible course of action considering
    new stackplot features will almost certainly require keyword arguments
    anyway.
  8. Damon McDougall
  9. Damon McDougall

    Added stackplot to list of pyplot commands.

    dmcdougall authored
    pyplot.py now contains the necessary information to make stackplot work
    inside of pyplot.
  10. Damon McDougall

    Added support for custom colour cycle.

    dmcdougall authored
    New keyword argument 'colors' can be passed to allow custom colouring of
    the stacked areas in a stacked area plot.
  11. Damon McDougall
Commits on Jul 5, 2012
  1. Damon McDougall

    Added stackplot unit test.

    dmcdougall authored
    Test images added. Unit test writted and unit test added to default
    tests in __init__.py
Commits on Jul 6, 2012
  1. Damon McDougall

    Removed superfluous file.

    dmcdougall authored
This page is out of date. Refresh to see the latest.
3  CHANGELOG
View
@@ -32,6 +32,9 @@
the linear portion relative to the logarithmic portion to be
adjusted. - MGD
+2012-04-14 Added new plot style: stackplot. This new feature supports stacked
+ area plots. - Damon McDougall
+
2012-04-06 When path clipping changes a LINETO to a MOVETO, it also
changes any CLOSEPOLY command to a LINETO to the initial
point. This fixes a problem with pdf and svg where the
2  boilerplate.py
View
@@ -69,7 +69,6 @@ def %(func)s(%(argspec)s):
return %(ret)s
"""
-
# Used for colormap functions
CMAP_TEMPLATE = AUTOGEN_MSG + """
def {name}():
@@ -131,6 +130,7 @@ def boilerplate_gen():
'semilogy',
'specgram',
#'spy',
+ 'stackplot',
'stem',
'step',
'streamplot',
18 examples/pylab_examples/stackplot_demo.py
View
@@ -0,0 +1,18 @@
+import numpy as np
+from matplotlib import pyplot as plt
+
+fnx = lambda : np.random.randint(5, 50, 10)
+y = np.row_stack((fnx(), fnx(), fnx()))
+x = np.arange(10)
+
+y1, y2, y3 = fnx(), fnx(), fnx()
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.stackplot(x, y)
+plt.show()
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.stackplot(x, y1, y2, y3)
+plt.show()
3  lib/matplotlib/__init__.py
View
@@ -992,7 +992,8 @@ def tk_window_focus():
'matplotlib.tests.test_text',
'matplotlib.tests.test_tightlayout',
'matplotlib.tests.test_delaunay',
- 'matplotlib.tests.test_legend'
+ 'matplotlib.tests.test_legend',
+ 'matplotlib.tests.test_stackplot'
]
def test(verbosity=1):
5 lib/matplotlib/axes.py
View
@@ -29,6 +29,7 @@
import matplotlib.spines as mspines
import matplotlib.quiver as mquiver
import matplotlib.scale as mscale
+import matplotlib.stackplot as mstack
import matplotlib.streamplot as mstream
import matplotlib.table as mtable
import matplotlib.text as mtext
@@ -6408,6 +6409,10 @@ def quiver(self, *args, **kw):
return q
quiver.__doc__ = mquiver.Quiver.quiver_doc
+ def stackplot(self, x, *args, **kwargs):
+ return mstack.stackplot(self, x, *args, **kwargs)
+ stackplot.__doc__ = mstack.stackplot.__doc__
+
def streamplot(self, x, y, u, v, density=1, linewidth=None, color=None,
cmap=None, norm=None, arrowsize=1, arrowstyle='-|>',
minlength=0.1):
19 lib/matplotlib/pyplot.py
View
@@ -1616,6 +1616,7 @@ def plotting():
until they have been closed; in interactive mode,
show generally has no effect.
specgram a spectrogram plot
+ stackplot make a stacked plot
stem make a stem plot
subplot make a subplot (numrows, numcols, axesnum)
table add a table to the axes
@@ -2960,6 +2961,24 @@ def specgram(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
+@autogen_docstring(Axes.stackplot)
+def stackplot(x, *args, **kwargs):
+ ax = gca()
+ # allow callers to override the hold state by passing hold=True|False
+ washold = ax.ishold()
+ hold = kwargs.pop('hold', None)
+ if hold is not None:
+ ax.hold(hold)
+ try:
+ ret = ax.stackplot(x, *args, **kwargs)
+ draw_if_interactive()
+ finally:
+ ax.hold(washold)
+
+ return ret
+
+# This function was autogenerated by boilerplate.py. Do not edit as
+# changes will be lost
@autogen_docstring(Axes.stem)
def stem(x, y, linefmt='b-', markerfmt='bo', basefmt='r-', bottom=None,
label=None, hold=None):
60 lib/matplotlib/stackplot.py
View
@@ -0,0 +1,60 @@
+"""
+Stacked area plot for 1D arrays inspired by Douglas Y'barbo's stackoverflow
+answer:
+http://stackoverflow.com/questions/2225995/how-can-i-create-stacked-line-graph-with-matplotlib
+
+(http://stackoverflow.com/users/66549/doug)
+
+"""
+import numpy as np
+import matplotlib
+
+__all__ = ['stackplot']
+
+
+def stackplot(axes, x, *args, **kwargs):
+ """Draws a stacked area plot.
+
+ Parameters
+ ----------
+ *x* : 1d array of dimension N
+ *y* : 2d array of dimension MxN, OR any number 1d arrays each of dimension
Michael Droettboom Owner
mdboom added a note

We should probably clarify here what's in the comment below: that the data is not "pre-stacked".

It might also be nice for y to be either a 2d array of MxN, or a variable number of y arguments (which would be stacked implicitly here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ 1xN. The data is assumed to be unstacked. Each of the following
+ calls is legal:
+
+ stackplot(x, y) # where y is MxN
+ staclplot(x, y1, y2, y3, y4) # where y1, y2, y3, y4, are all 1xNm
+
+ Keyword arguments:
+ *colors* : A list or tuple of colors. These will be cycled through and
+ used to colour the stacked areas.
+ All other keyword arguments are passed to
+ :func:`~matplotlib.Axes.fill_between`
+
+ Returns
+ -------
+ *r* : A list of :class:`~matplotlib.collections.PolyCollection`, one for
+ each element in the stacked area plot.
+ """
+
+ if len(args) == 1:
+ y = np.atleast_2d(*args)
+ elif len(args) > 1:
+ y = np.row_stack(args)
+
+ colors = kwargs.pop('colors', None)
+ if colors is not None:
+ axes.set_color_cycle(colors)
+
+ # Assume data passed has not been 'stacked', so stack it here.
+ y_stack = np.cumsum(y, axis=0)
+
+ r = []
+
+ # Color between x = 0 and the first array.
+ r.append(axes.fill_between(x, 0, y_stack[0,:], facecolor=axes._get_lines.color_cycle.next(), **kwargs))
+
+ # Color between array i-1 and array i
+ for i in xrange(len(y)-1):
+ r.append(axes.fill_between(x, y_stack[i,:], y_stack[i+1,:], facecolor=axes._get_lines.color_cycle.next(), **kwargs))
+ return r
BIN  lib/matplotlib/tests/baseline_images/test_stackplot/stackplot_test_image.pdf
View
Binary file not shown
BIN  lib/matplotlib/tests/baseline_images/test_stackplot/stackplot_test_image.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
661 lib/matplotlib/tests/baseline_images/test_stackplot/stackplot_test_image.svg
View
@@ -0,0 +1,661 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Created with matplotlib (http://matplotlib.sourceforge.net/) -->
+<svg height="432pt" version="1.1" viewBox="0 0 576 432" width="576pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <defs>
+ <style type="text/css">
+*{stroke-linecap:square;stroke-linejoin:round;}
+ </style>
+ </defs>
+ <g id="figure_1">
+ <g id="patch_1">
+ <path d="
+M0 432
+L576 432
+L576 0
+L0 0
+z
+" style="fill:#ffffff;"/>
+ </g>
+ <g id="axes_1">
+ <g id="patch_2">
+ <path d="
+M72 388.8
+L518.4 388.8
+L518.4 43.2
+L72 43.2
+z
+" style="fill:#ffffff;"/>
+ </g>
+ <g id="PolyCollection_1">
+ <defs>
+ <path d="
+M72 -43.2
+L72 -43.2
+L121.6 -43.2
+L171.2 -43.2
+L220.8 -43.2
+L270.4 -43.2
+L320 -43.2
+L369.6 -43.2
+L419.2 -43.2
+L468.8 -43.2
+L518.4 -43.2
+L518.4 -92.5714
+L518.4 -92.5714
+L468.8 -87.0857
+L419.2 -81.6
+L369.6 -76.1143
+L320 -70.6286
+L270.4 -65.1429
+L220.8 -59.6571
+L171.2 -54.1714
+L121.6 -48.6857
+L72 -43.2
+z
+" id="C0_0_7ebce71036"/>
+ </defs>
+ <g clip-path="url(#p7ff5b81e1d)">
+ <use style="fill:#0000ff;stroke:#000000;stroke-linecap:butt;" x="0" xlink:href="#C0_0_7ebce71036" y="432.0"/>
+ </g>
+ </g>
+ <g id="PolyCollection_2">
+ <defs>
+ <path d="
+M72 -48.1371
+L72 -43.2
+L121.6 -48.6857
+L171.2 -54.1714
+L220.8 -59.6571
+L270.4 -65.1429
+L320 -70.6286
+L369.6 -76.1143
+L419.2 -81.6
+L468.8 -87.0857
+L518.4 -92.5714
+L518.4 -196.251
+L518.4 -196.251
+L468.8 -179.794
+L419.2 -163.337
+L369.6 -146.88
+L320 -130.423
+L270.4 -113.966
+L220.8 -97.5086
+L171.2 -81.0514
+L121.6 -64.5943
+L72 -48.1371
+z
+" id="C1_0_01c5bb7e1c"/>
+ </defs>
+ <g clip-path="url(#p7ff5b81e1d)">
+ <use style="fill:#008000;stroke:#000000;stroke-linecap:butt;" x="0" xlink:href="#C1_0_01c5bb7e1c" y="432.0"/>
+ </g>
+ </g>
+ <g id="PolyCollection_3">
+ <defs>
+ <path d="
+M72 -58.0114
+L72 -48.1371
+L121.6 -64.5943
+L171.2 -81.0514
+L220.8 -97.5086
+L270.4 -113.966
+L320 -130.423
+L369.6 -146.88
+L419.2 -163.337
+L468.8 -179.794
+L518.4 -196.251
+L518.4 -354.24
+L518.4 -354.24
+L468.8 -321.326
+L419.2 -288.411
+L369.6 -255.497
+L320 -222.583
+L270.4 -189.669
+L220.8 -156.754
+L171.2 -123.84
+L121.6 -90.9257
+L72 -58.0114
+z
+" id="C2_0_a5baad2d3c"/>
+ </defs>
+ <g clip-path="url(#p7ff5b81e1d)">
+ <use style="fill:#ff0000;stroke:#000000;stroke-linecap:butt;" x="0" xlink:href="#C2_0_a5baad2d3c" y="432.0"/>
+ </g>
+ </g>
+ <g id="matplotlib.axis_1">
+ <g id="xtick_1">
+ <g id="line2d_1">
+ <defs>
+ <path d="
+M0 0
+L0 -4" id="mcb557df647" style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;"/>
+ </defs>
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="72.0" xlink:href="#mcb557df647" y="388.8"/>
+ </g>
+ </g>
+ <g id="line2d_2">
+ <defs>
+ <path d="
+M0 0
+L0 4" id="mdad270ee8e" style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;"/>
+ </defs>
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="72.0" xlink:href="#mdad270ee8e" y="43.2"/>
+ </g>
+ </g>
+ <g id="text_1">
+ <!-- 0 -->
+ <defs>
+ <path d="
+M31.7812 66.4062
+Q24.1719 66.4062 20.3281 58.9062
+Q16.5 51.4219 16.5 36.375
+Q16.5 21.3906 20.3281 13.8906
+Q24.1719 6.39062 31.7812 6.39062
+Q39.4531 6.39062 43.2812 13.8906
+Q47.125 21.3906 47.125 36.375
+Q47.125 51.4219 43.2812 58.9062
+Q39.4531 66.4062 31.7812 66.4062
+M31.7812 74.2188
+Q44.0469 74.2188 50.5156 64.5156
+Q56.9844 54.8281 56.9844 36.375
+Q56.9844 17.9688 50.5156 8.26562
+Q44.0469 -1.42188 31.7812 -1.42188
+Q19.5312 -1.42188 13.0625 8.26562
+Q6.59375 17.9688 6.59375 36.375
+Q6.59375 54.8281 13.0625 64.5156
+Q19.5312 74.2188 31.7812 74.2188" id="BitstreamVeraSans-Roman-30"/>
+ </defs>
+ <g transform="translate(68.9765625 401.70625)scale(0.12 -0.12)">
+ <use xlink:href="#BitstreamVeraSans-Roman-30"/>
+ </g>
+ </g>
+ </g>
+ <g id="xtick_2">
+ <g id="line2d_3">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="161.28" xlink:href="#mcb557df647" y="388.8"/>
+ </g>
+ </g>
+ <g id="line2d_4">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="161.28" xlink:href="#mdad270ee8e" y="43.2"/>
+ </g>
+ </g>
+ <g id="text_2">
+ <!-- 2 -->
+ <defs>
+ <path d="
+M19.1875 8.29688
+L53.6094 8.29688
+L53.6094 0
+L7.32812 0
+L7.32812 8.29688
+Q12.9375 14.1094 22.625 23.8906
+Q32.3281 33.6875 34.8125 36.5312
+Q39.5469 41.8438 41.4219 45.5312
+Q43.3125 49.2188 43.3125 52.7812
+Q43.3125 58.5938 39.2344 62.25
+Q35.1562 65.9219 28.6094 65.9219
+Q23.9688 65.9219 18.8125 64.3125
+Q13.6719 62.7031 7.8125 59.4219
+L7.8125 69.3906
+Q13.7656 71.7812 18.9375 73
+Q24.125 74.2188 28.4219 74.2188
+Q39.75 74.2188 46.4844 68.5469
+Q53.2188 62.8906 53.2188 53.4219
+Q53.2188 48.9219 51.5312 44.8906
+Q49.8594 40.875 45.4062 35.4062
+Q44.1875 33.9844 37.6406 27.2188
+Q31.1094 20.4531 19.1875 8.29688" id="BitstreamVeraSans-Roman-32"/>
+ </defs>
+ <g transform="translate(158.503125 401.70625)scale(0.12 -0.12)">
+ <use xlink:href="#BitstreamVeraSans-Roman-32"/>
+ </g>
+ </g>
+ </g>
+ <g id="xtick_3">
+ <g id="line2d_5">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="250.56" xlink:href="#mcb557df647" y="388.8"/>
+ </g>
+ </g>
+ <g id="line2d_6">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="250.56" xlink:href="#mdad270ee8e" y="43.2"/>
+ </g>
+ </g>
+ <g id="text_3">
+ <!-- 4 -->
+ <defs>
+ <path d="
+M37.7969 64.3125
+L12.8906 25.3906
+L37.7969 25.3906
+z
+
+M35.2031 72.9062
+L47.6094 72.9062
+L47.6094 25.3906
+L58.0156 25.3906
+L58.0156 17.1875
+L47.6094 17.1875
+L47.6094 0
+L37.7969 0
+L37.7969 17.1875
+L4.89062 17.1875
+L4.89062 26.7031
+z
+" id="BitstreamVeraSans-Roman-34"/>
+ </defs>
+ <g transform="translate(247.3725 401.54875)scale(0.12 -0.12)">
+ <use xlink:href="#BitstreamVeraSans-Roman-34"/>
+ </g>
+ </g>
+ </g>
+ <g id="xtick_4">
+ <g id="line2d_7">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="339.84" xlink:href="#mcb557df647" y="388.8"/>
+ </g>
+ </g>
+ <g id="line2d_8">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="339.84" xlink:href="#mdad270ee8e" y="43.2"/>
+ </g>
+ </g>
+ <g id="text_4">
+ <!-- 6 -->
+ <defs>
+ <path d="
+M33.0156 40.375
+Q26.375 40.375 22.4844 35.8281
+Q18.6094 31.2969 18.6094 23.3906
+Q18.6094 15.5312 22.4844 10.9531
+Q26.375 6.39062 33.0156 6.39062
+Q39.6562 6.39062 43.5312 10.9531
+Q47.4062 15.5312 47.4062 23.3906
+Q47.4062 31.2969 43.5312 35.8281
+Q39.6562 40.375 33.0156 40.375
+M52.5938 71.2969
+L52.5938 62.3125
+Q48.875 64.0625 45.0938 64.9844
+Q41.3125 65.9219 37.5938 65.9219
+Q27.8281 65.9219 22.6719 59.3281
+Q17.5312 52.7344 16.7969 39.4062
+Q19.6719 43.6562 24.0156 45.9219
+Q28.375 48.1875 33.5938 48.1875
+Q44.5781 48.1875 50.9531 41.5156
+Q57.3281 34.8594 57.3281 23.3906
+Q57.3281 12.1562 50.6875 5.35938
+Q44.0469 -1.42188 33.0156 -1.42188
+Q20.3594 -1.42188 13.6719 8.26562
+Q6.98438 17.9688 6.98438 36.375
+Q6.98438 53.6562 15.1875 63.9375
+Q23.3906 74.2188 37.2031 74.2188
+Q40.9219 74.2188 44.7031 73.4844
+Q48.4844 72.75 52.5938 71.2969" id="BitstreamVeraSans-Roman-36"/>
+ </defs>
+ <g transform="translate(336.819375 401.70625)scale(0.12 -0.12)">
+ <use xlink:href="#BitstreamVeraSans-Roman-36"/>
+ </g>
+ </g>
+ </g>
+ <g id="xtick_5">
+ <g id="line2d_9">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="429.12" xlink:href="#mcb557df647" y="388.8"/>
+ </g>
+ </g>
+ <g id="line2d_10">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="429.12" xlink:href="#mdad270ee8e" y="43.2"/>
+ </g>
+ </g>
+ <g id="text_5">
+ <!-- 8 -->
+ <defs>
+ <path d="
+M31.7812 34.625
+Q24.75 34.625 20.7188 30.8594
+Q16.7031 27.0938 16.7031 20.5156
+Q16.7031 13.9219 20.7188 10.1562
+Q24.75 6.39062 31.7812 6.39062
+Q38.8125 6.39062 42.8594 10.1719
+Q46.9219 13.9688 46.9219 20.5156
+Q46.9219 27.0938 42.8906 30.8594
+Q38.875 34.625 31.7812 34.625
+M21.9219 38.8125
+Q15.5781 40.375 12.0312 44.7188
+Q8.5 49.0781 8.5 55.3281
+Q8.5 64.0625 14.7188 69.1406
+Q20.9531 74.2188 31.7812 74.2188
+Q42.6719 74.2188 48.875 69.1406
+Q55.0781 64.0625 55.0781 55.3281
+Q55.0781 49.0781 51.5312 44.7188
+Q48 40.375 41.7031 38.8125
+Q48.8281 37.1562 52.7969 32.3125
+Q56.7812 27.4844 56.7812 20.5156
+Q56.7812 9.90625 50.3125 4.23438
+Q43.8438 -1.42188 31.7812 -1.42188
+Q19.7344 -1.42188 13.25 4.23438
+Q6.78125 9.90625 6.78125 20.5156
+Q6.78125 27.4844 10.7812 32.3125
+Q14.7969 37.1562 21.9219 38.8125
+M18.3125 54.3906
+Q18.3125 48.7344 21.8438 45.5625
+Q25.3906 42.3906 31.7812 42.3906
+Q38.1406 42.3906 41.7188 45.5625
+Q45.3125 48.7344 45.3125 54.3906
+Q45.3125 60.0625 41.7188 63.2344
+Q38.1406 66.4062 31.7812 66.4062
+Q25.3906 66.4062 21.8438 63.2344
+Q18.3125 60.0625 18.3125 54.3906" id="BitstreamVeraSans-Roman-38"/>
+ </defs>
+ <g transform="translate(426.12 401.70625)scale(0.12 -0.12)">
+ <use xlink:href="#BitstreamVeraSans-Roman-38"/>
+ </g>
+ </g>
+ </g>
+ <g id="xtick_6">
+ <g id="line2d_11">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="518.4" xlink:href="#mcb557df647" y="388.8"/>
+ </g>
+ </g>
+ <g id="line2d_12">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="518.4" xlink:href="#mdad270ee8e" y="43.2"/>
+ </g>
+ </g>
+ <g id="text_6">
+ <!-- 10 -->
+ <defs>
+ <path d="
+M12.4062 8.29688
+L28.5156 8.29688
+L28.5156 63.9219
+L10.9844 60.4062
+L10.9844 69.3906
+L28.4219 72.9062
+L38.2812 72.9062
+L38.2812 8.29688
+L54.3906 8.29688
+L54.3906 0
+L12.4062 0
+z
+" id="BitstreamVeraSans-Roman-31"/>
+ </defs>
+ <g transform="translate(511.8225 401.70625)scale(0.12 -0.12)">
+ <use xlink:href="#BitstreamVeraSans-Roman-31"/>
+ <use x="63.623046875" xlink:href="#BitstreamVeraSans-Roman-30"/>
+ </g>
+ </g>
+ </g>
+ </g>
+ <g id="matplotlib.axis_2">
+ <g id="ytick_1">
+ <g id="line2d_13">
+ <defs>
+ <path d="
+M0 0
+L4 0" id="mc8fcea1516" style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;"/>
+ </defs>
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="72.0" xlink:href="#mc8fcea1516" y="388.8"/>
+ </g>
+ </g>
+ <g id="line2d_14">
+ <defs>
+ <path d="
+M0 0
+L-4 0" id="m0d5b0a6425" style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;"/>
+ </defs>
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="518.4" xlink:href="#m0d5b0a6425" y="388.8"/>
+ </g>
+ </g>
+ <g id="text_7">
+ <!-- 0 -->
+ <g transform="translate(61.953125 393.1678125)scale(0.12 -0.12)">
+ <use xlink:href="#BitstreamVeraSans-Roman-30"/>
+ </g>
+ </g>
+ </g>
+ <g id="ytick_2">
+ <g id="line2d_15">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="72.0" xlink:href="#mc8fcea1516" y="339.428571429"/>
+ </g>
+ </g>
+ <g id="line2d_16">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="518.4" xlink:href="#m0d5b0a6425" y="339.428571429"/>
+ </g>
+ </g>
+ <g id="text_8">
+ <!-- 10 -->
+ <g transform="translate(54.845 343.796383929)scale(0.12 -0.12)">
+ <use xlink:href="#BitstreamVeraSans-Roman-31"/>
+ <use x="63.623046875" xlink:href="#BitstreamVeraSans-Roman-30"/>
+ </g>
+ </g>
+ </g>
+ <g id="ytick_3">
+ <g id="line2d_17">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="72.0" xlink:href="#mc8fcea1516" y="290.057142857"/>
+ </g>
+ </g>
+ <g id="line2d_18">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="518.4" xlink:href="#m0d5b0a6425" y="290.057142857"/>
+ </g>
+ </g>
+ <g id="text_9">
+ <!-- 20 -->
+ <g transform="translate(54.40625 294.424955357)scale(0.12 -0.12)">
+ <use xlink:href="#BitstreamVeraSans-Roman-32"/>
+ <use x="63.623046875" xlink:href="#BitstreamVeraSans-Roman-30"/>
+ </g>
+ </g>
+ </g>
+ <g id="ytick_4">
+ <g id="line2d_19">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="72.0" xlink:href="#mc8fcea1516" y="240.685714286"/>
+ </g>
+ </g>
+ <g id="line2d_20">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="518.4" xlink:href="#m0d5b0a6425" y="240.685714286"/>
+ </g>
+ </g>
+ <g id="text_10">
+ <!-- 30 -->
+ <defs>
+ <path d="
+M40.5781 39.3125
+Q47.6562 37.7969 51.625 33
+Q55.6094 28.2188 55.6094 21.1875
+Q55.6094 10.4062 48.1875 4.48438
+Q40.7656 -1.42188 27.0938 -1.42188
+Q22.5156 -1.42188 17.6562 -0.515625
+Q12.7969 0.390625 7.625 2.20312
+L7.625 11.7188
+Q11.7188 9.32812 16.5938 8.10938
+Q21.4844 6.89062 26.8125 6.89062
+Q36.0781 6.89062 40.9375 10.5469
+Q45.7969 14.2031 45.7969 21.1875
+Q45.7969 27.6406 41.2812 31.2656
+Q36.7656 34.9062 28.7188 34.9062
+L20.2188 34.9062
+L20.2188 43.0156
+L29.1094 43.0156
+Q36.375 43.0156 40.2344 45.9219
+Q44.0938 48.8281 44.0938 54.2969
+Q44.0938 59.9062 40.1094 62.9062
+Q36.1406 65.9219 28.7188 65.9219
+Q24.6562 65.9219 20.0156 65.0312
+Q15.375 64.1562 9.8125 62.3125
+L9.8125 71.0938
+Q15.4375 72.6562 20.3438 73.4375
+Q25.25 74.2188 29.5938 74.2188
+Q40.8281 74.2188 47.3594 69.1094
+Q53.9062 64.0156 53.9062 55.3281
+Q53.9062 49.2656 50.4375 45.0938
+Q46.9688 40.9219 40.5781 39.3125" id="BitstreamVeraSans-Roman-33"/>
+ </defs>
+ <g transform="translate(54.441875 245.053526786)scale(0.12 -0.12)">
+ <use xlink:href="#BitstreamVeraSans-Roman-33"/>
+ <use x="63.623046875" xlink:href="#BitstreamVeraSans-Roman-30"/>
+ </g>
+ </g>
+ </g>
+ <g id="ytick_5">
+ <g id="line2d_21">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="72.0" xlink:href="#mc8fcea1516" y="191.314285714"/>
+ </g>
+ </g>
+ <g id="line2d_22">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="518.4" xlink:href="#m0d5b0a6425" y="191.314285714"/>
+ </g>
+ </g>
+ <g id="text_11">
+ <!-- 40 -->
+ <g transform="translate(54.11375 195.682098214)scale(0.12 -0.12)">
+ <use xlink:href="#BitstreamVeraSans-Roman-34"/>
+ <use x="63.623046875" xlink:href="#BitstreamVeraSans-Roman-30"/>
+ </g>
+ </g>
+ </g>
+ <g id="ytick_6">
+ <g id="line2d_23">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="72.0" xlink:href="#mc8fcea1516" y="141.942857143"/>
+ </g>
+ </g>
+ <g id="line2d_24">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="518.4" xlink:href="#m0d5b0a6425" y="141.942857143"/>
+ </g>
+ </g>
+ <g id="text_12">
+ <!-- 50 -->
+ <defs>
+ <path d="
+M10.7969 72.9062
+L49.5156 72.9062
+L49.5156 64.5938
+L19.8281 64.5938
+L19.8281 46.7344
+Q21.9688 47.4688 24.1094 47.8281
+Q26.2656 48.1875 28.4219 48.1875
+Q40.625 48.1875 47.75 41.5
+Q54.8906 34.8125 54.8906 23.3906
+Q54.8906 11.625 47.5625 5.09375
+Q40.2344 -1.42188 26.9062 -1.42188
+Q22.3125 -1.42188 17.5469 -0.640625
+Q12.7969 0.140625 7.71875 1.70312
+L7.71875 11.625
+Q12.1094 9.23438 16.7969 8.0625
+Q21.4844 6.89062 26.7031 6.89062
+Q35.1562 6.89062 40.0781 11.3281
+Q45.0156 15.7656 45.0156 23.3906
+Q45.0156 31 40.0781 35.4375
+Q35.1562 39.8906 26.7031 39.8906
+Q22.75 39.8906 18.8125 39.0156
+Q14.8906 38.1406 10.7969 36.2812
+z
+" id="BitstreamVeraSans-Roman-35"/>
+ </defs>
+ <g transform="translate(54.453125 146.310669643)scale(0.12 -0.12)">
+ <use xlink:href="#BitstreamVeraSans-Roman-35"/>
+ <use x="63.623046875" xlink:href="#BitstreamVeraSans-Roman-30"/>
+ </g>
+ </g>
+ </g>
+ <g id="ytick_7">
+ <g id="line2d_25">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="72.0" xlink:href="#mc8fcea1516" y="92.5714285714"/>
+ </g>
+ </g>
+ <g id="line2d_26">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="518.4" xlink:href="#m0d5b0a6425" y="92.5714285714"/>
+ </g>
+ </g>
+ <g id="text_13">
+ <!-- 60 -->
+ <g transform="translate(54.365 96.9392410714)scale(0.12 -0.12)">
+ <use xlink:href="#BitstreamVeraSans-Roman-36"/>
+ <use x="63.623046875" xlink:href="#BitstreamVeraSans-Roman-30"/>
+ </g>
+ </g>
+ </g>
+ <g id="ytick_8">
+ <g id="line2d_27">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="72.0" xlink:href="#mc8fcea1516" y="43.2"/>
+ </g>
+ </g>
+ <g id="line2d_28">
+ <g>
+ <use style="stroke:#000000;stroke-linecap:butt;stroke-width:0.5;" x="518.4" xlink:href="#m0d5b0a6425" y="43.2"/>
+ </g>
+ </g>
+ <g id="text_14">
+ <!-- 70 -->
+ <defs>
+ <path d="
+M8.20312 72.9062
+L55.0781 72.9062
+L55.0781 68.7031
+L28.6094 0
+L18.3125 0
+L43.2188 64.5938
+L8.20312 64.5938
+z
+" id="BitstreamVeraSans-Roman-37"/>
+ </defs>
+ <g transform="translate(54.51125 47.5678125)scale(0.12 -0.12)">
+ <use xlink:href="#BitstreamVeraSans-Roman-37"/>
+ <use x="63.623046875" xlink:href="#BitstreamVeraSans-Roman-30"/>
+ </g>
+ </g>
+ </g>
+ </g>
+ <g id="patch_3">
+ <path d="
+M72 43.2
+L518.4 43.2" style="fill:none;stroke:#000000;"/>
+ </g>
+ <g id="patch_4">
+ <path d="
+M518.4 388.8
+L518.4 43.2" style="fill:none;stroke:#000000;"/>
+ </g>
+ <g id="patch_5">
+ <path d="
+M72 388.8
+L518.4 388.8" style="fill:none;stroke:#000000;"/>
+ </g>
+ <g id="patch_6">
+ <path d="
+M72 388.8
+L72 43.2" style="fill:none;stroke:#000000;"/>
+ </g>
+ </g>
+ </g>
+ <defs>
+ <clipPath id="p7ff5b81e1d">
+ <rect height="345.6" width="446.4" x="72.0" y="43.2"/>
+ </clipPath>
+ </defs>
+</svg>
14 lib/matplotlib/tests/test_stackplot.py
View
@@ -0,0 +1,14 @@
+import numpy as np
+import matplotlib
+from matplotlib.testing.decorators import image_comparison
+import matplotlib.pyplot as plt
+
+@image_comparison(baseline_images=['stackplot_test_image'])
+def test_stackplot():
+ fig = plt.figure()
+ x = np.linspace(0, 10, 10)
+ y1 = 1.0 * x
+ y2 = 2.0 * x + 1
+ y3 = 3.0 * x + 2
+ ax = fig.add_subplot(1, 1, 1)
+ ax.stackplot(x, y1, y2, y3)
Something went wrong with that request. Please try again.