Re: fill in harberger triangle

*To*: mathgroup at smc.vnet.net*Subject*: [mg115630] Re: fill in harberger triangle*From*: Helen Read <readhpr at gmail.com>*Date*: Mon, 17 Jan 2011 05:36:35 -0500 (EST)*References*: <iguimb$8pe$1@smc.vnet.net>

On 1/16/2011 5:52 AM, DrMajorBob wrote: > I don't like the logic or paradigm of Epilog, so I'd do it this way: > > a = 10.2; > e = 1.4; > q[p_] = 10.2 p^1.4; > lowerBound = p /. Solve[q[p] == 100, p][[1]] // Quiet; > Show[Plot[q[p], {p, 0, 30}, PlotRange -> {0, Automatic}], > Plot[q[p], {p, lowerBound, 20}, Filling -> 100], > Graphics[{Line[{{0, 100}, {30, 100}}], Line[{{20, 0}, {20, 1200}}]}]] > > A "complete" graphics object covering the full range of x and y values > must go first, or things go very wrong. I greatly dislike this behavior of Show that was introduced in, I think, v.6. Prior to that, Show came up with a reasonable PlotRange no matter what order the individual graphics. But now, by default it takes the PlotRange from the first graphic listed. I remember much discussion of this when v.6 came out, with some folks from WRI explaining why the new behavior is supposedly a Good Thing. Something about wanting the PlotRange from the first object because of options like Filling->Axis. Well, that's pretty much never the behavior that I would want, and if for some reason I did want the PlotRange from the first object listed, I would specify a PlotRange explicitly within Show. Show[{ , }, PlotRange->Automatic] will nearly always produce what I do want. Unfortunately, setting SetOptions[Show, PlotRange -> Automatic] doesn't even work, because "PlotRange is not a known option for Show" ! It is a nuisance to have to stick PlotRange->Automatic in there every time I use Show. My students get burned on this all the time when using Show, because they don't use Show that often (usually they just plot things all in one plot to begin with), and so they forget about the need for PlotRange->Automatic. So they end up with these awful plots, things all cut off, and they don't understand why, and can never remember how to fix it. It has seemed to me all along that PlotRange->Automatic ought to be the default behavior of Show. There could always be an option for using the PlotRange and other options from the first graphic opject. Show[{,},Options->First] or something. > This shows nothing but the filled area: > > a = 10.2; > e = 1.4; > q[p_] = 10.2 p^1.4; > lowerBound = p /. Solve[q[p] == 100, p][[1]] // Quiet; > Show[Plot[q[p], {p, lowerBound, 20}, Filling -> 100], > Plot[q[p], {p, 0, 30}, PlotRange -> {0, Automatic}], > Graphics[{Line[{{0, 100}, {30, 100}}], Line[{{20, 0}, {20, 1200}}]}]] You can fix it with: Show[Plot[q[p], {p, lowerBound, 20}, Filling -> 100], Plot[q[p], {p, 0, 30}, PlotRange -> {0, Automatic}], Graphics[{Line[{{0, 100}, {30, 100}}], Line[{{20, 0}, {20, 1200}}]}], PlotRange -> Automatic, AxesOrigin -> {0, 0}] > > And this shows nothing but the lines, with a ridiculous aspect ratio: > a = 10.2; > e = 1.4; > q[p_] = 10.2 p^1.4; > lowerBound = p /. Solve[q[p] == 100, p][[1]] // Quiet; > Show[Graphics[{Line[{{0, 100}, {30, 100}}], > Line[{{20, 0}, {20, 1200}}]}], > Plot[q[p], {p, 0, 30}, PlotRange -> {0, Automatic}], > Plot[q[p], {p, lowerBound, 20}, Filling -> 100]] That one takes a bit more work to fix, because it's getting other unwanted options from the first graphic besides the range. Show[Graphics[{Line[{{0, 100}, {30, 100}}], Line[{{20, 0}, {20, 1200}}]}], Plot[q[p], {p, 0, 30}, PlotRange -> {0, Automatic}], Plot[q[p], {p, lowerBound, 20}, Filling -> 100], AspectRatio -> 1/GoldenRatio, PlotRange -> Automatic, AxesOrigin -> {0, 0}, Axes -> True] > Stupid, I know... but that's the way it is. It's annoying for sure, and I really can't disagree with stupid. -- Helen Read University of Vermont