ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 29 Mar 2013 22:46:05 +0100Fill between two curveshttps://ask.sagemath.org/question/9955/fill-between-two-curves/I am attempting to fill the area between two curves. To more clearly illustrate what I am trying to accomplish, I would like to represent the area of the following integral:
integrate x-x^2 from 0 to 1
I can currently show the area under `x` with `fill=True`, but this is not what I want. What I want is for the fill to extend only to `x^2` rather than all the way down to the x axis.Fri, 29 Mar 2013 22:03:56 +0100https://ask.sagemath.org/question/9955/fill-between-two-curves/Answer by ppurka for <p>I am attempting to fill the area between two curves. To more clearly illustrate what I am trying to accomplish, I would like to represent the area of the following integral:</p>
<pre><code>integrate x-x^2 from 0 to 1
</code></pre>
<p>I can currently show the area under <code>x</code> with <code>fill=True</code>, but this is not what I want. What I want is for the fill to extend only to <code>x^2</code> rather than all the way down to the x axis.</p>
https://ask.sagemath.org/question/9955/fill-between-two-curves/?answer=14706#post-id-14706Use a dict `{<index of first curve>: [<index of second curve>]}`, like this:
sage: plot([x, x^2], fill={0:[1]})
See the [plot documentation](http://www.sagemath.org/doc/reference/plotting/sage/plot/plot.html#sage.plot.plot.plot) for more examples.Fri, 29 Mar 2013 22:45:02 +0100https://ask.sagemath.org/question/9955/fill-between-two-curves/?answer=14706#post-id-14706Answer by kcrisman for <p>I am attempting to fill the area between two curves. To more clearly illustrate what I am trying to accomplish, I would like to represent the area of the following integral:</p>
<pre><code>integrate x-x^2 from 0 to 1
</code></pre>
<p>I can currently show the area under <code>x</code> with <code>fill=True</code>, but this is not what I want. What I want is for the fill to extend only to <code>x^2</code> rather than all the way down to the x axis.</p>
https://ask.sagemath.org/question/9955/fill-between-two-curves/?answer=14707#post-id-14707See [here](http://sagemath.org/doc/reference/plotting/sage/plot/plot.html#sage.plot.plot.plot) for a slew of fill options. Probably one of these will fit your needs.
sage: plot(x,(x,0,1),fill=x^2)
sage: plot([x,x^2],(x,0,1),fill={0:[1]})
Fri, 29 Mar 2013 22:46:05 +0100https://ask.sagemath.org/question/9955/fill-between-two-curves/?answer=14707#post-id-14707