Ask Your Question

# 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.

edit retag close merge delete

## 2 Answers

Sort by ยป oldest newest most voted

See here 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]})

more

Use a dict {<index of first curve>: [<index of second curve>]}, like this:

sage: plot([x, x^2], fill={0:[1]})


See the plot documentation for more examples.

more

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2013-03-29 22:03:56 +0200

Seen: 2,282 times

Last updated: Mar 29 '13