Re: Filling Plots to the X-Axis for a Range of X Values
- To: mathgroup at smc.vnet.net
- Subject: [mg117776] Re: Filling Plots to the X-Axis for a Range of X Values
- From: Gregory Lypny <gregory.lypny at videotron.ca>
- Date: Thu, 31 Mar 2011 04:01:23 -0500 (EST)
Thank you David,
Another good solution. I also didn't know that we could mess around with antialiasing.
Regards,
Gregory
On Wed, Mar 30, 2011, at 9:17 AM, David Park wrote:
> Gregory,
>
> Here is your graphic in regular Mathematica using the Show statement. I've
> embellished it slightly by adding vertical lines on the filled region - just
> to show how you might do things like that.
>
> f[x_] := x^2
> Show[
> {Plot[f[x], {x, 2, 7}, Filling -> Axis,
> FillingStyle -> Lighter@Orange, PlotStyle -> None],
> Plot[f[x], {x, 0, 10}],
> Graphics[
> Style[{Line[{{2, 0}, {2, f[2]}}], Line[{{7, 0}, {7, f[7]}}]},
> Antialiasing -> False]]},
> AspectRatio -> 1,
> AxesOrigin -> {0, 0},
> PlotRange -> All]
>
> 1) It is necessary to use PlotRange->All, otherwise it is picked up from the
> first Plot.
> 2) We draw the filled region first with PlotStyle->None so that the second
> Plot won't overlay a line that might not exactly register with the first
> line (because the two plots won't use the same points).
> 3) We have to enclose the vertical lines in a Graphics statement to get them
> on the same graphics level as the Plot statements.
> 4) Style with Antialiasing->False was used so the vertical lines will both
> be sharp, otherwise the automatic Antialiasing might produce some fuzziness.
> This is useful for horizontal or vertical lines.
>
> Here is the same graphic using the Presentations package. It is a little
> more intuitive since everything is at the graphics primitive level and there
> is a simpler Aliasing command. You just draw one thing after another.
>
> << Presentations`
>
> f[x_] := x^2
> Draw2D[
> {Draw[f[x], {x, 2, 7}, Filling -> Axis,
> FillingStyle -> Lighter@Orange, PlotStyle -> None],
> Draw[f[x], {x, 0, 10}],
> Aliasing@{Line[{{2, 0}, {2, f[2]}}], Line[{{7, 0}, {7, f[7]}}]}},
> AspectRatio -> 1,
> Axes -> True]
>
>
> David Park
> djmpark at comcast.net
> http://home.comcast.net/~djmpark/
>
>
>
> From: Gregory Lypny [mailto:gregory.lypny at videotron.ca]
>
>
> Hello everyone,
>
> I'd like to fill a plot down to the x-axis but restrict the fill to lie
> between two x values, and am not sure how to do it. For example, if I plot
> a parabola f[x] = x^2, with x in the range ==E2==88==9210 to 10, I'd like to be
> able to fill to the x-axis between x = 2 and x = 7, essentially creating a
> filled column. Is there any way to do that?
>
> Regards,
>
> Gregory
>
>