Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
0

In sage plot: fill the area under a curve between two x-values.

asked 13 years ago

anonymous user

Anonymous

How do I fill the area under a curve between two x-values using sage plot?

For example, maybe I am using the following code:

plot(x(x-1)(x-2)+1,0,2,fill=True)

but I only want the area under the curve from x = 0.5 to x = 1.5 to be shaded in.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
6

answered 13 years ago

DSM gravatar image

If I'm understanding you correctly, then one way to do this is to take advantage of the fact you can add plots:

sage: f = x*(x-1)*(x-2)+1
sage: p = plot(f, 0.5, 1.5, fill=True) + plot(f, 0, 2)
sage: show(p)

partly shaded picture

Preview: (hide)
link

Comments

1

oh, okay, that makes sense, thank you!

Sonya gravatar imageSonya ( 13 years ago )

Good answer. At the same time, maybe we can support this option somehow without adding plots...

kcrisman gravatar imagekcrisman ( 13 years ago )

@kcrisman: Sure, we'd simply need to have fillxmin and fillxmax and use those instead. Right now it looks like fill is using xmin and xmax for both purposes. (You could probably achieve the same effect by playing games with the function specifications but that seemed like more work than the above..) That would be a good beginner-level ticket for someone who already knows Python.

DSM gravatar imageDSM ( 13 years ago )

Great, file it and maybe we can get it at Sage Days 35.5!

kcrisman gravatar imagekcrisman ( 13 years ago )
1

Did the feature get implemented? If not, how could I give it a try?

Radu gravatar imageRadu ( 11 years ago )

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 13 years ago

Seen: 4,955 times

Last updated: Nov 27 '11