# Contour Plot - L-Shaped

I am trying to plot a contour with an L-shaped form. I started by illustrating the contour function (horizontal, orange) and adding a line (vertical, black).

Clear["Global*"]
Bconstr[x_, y_, px_, py_, R_] = px*x + py*y - R;
f1[px_, py_, R_] := y /. Solve[Bconstr[x, y, px, py, R] == 0, y]
U8[x_, y_, a_, b_] := Min[a*x, b*y];
xstarvalue8[px_, py_, R_, a_, b_] := R/(px + a/b*py)
ystarvalue8[px_, py_, R_, a_, b_] := R/(b/a*px + py)
opt8[px_, py_, R_, a_, b_] := Evaluate[{xstarvalue8[px, py, R, a, b], ystarvalue8[px, py, R, a, b]}]
f8[px_, py_, R_, a_, b_] = Quiet[y /. Solve[U8[## & @@ opt8[px, py, R, a, b], a, b] == U8[x, y, a, b], y][[1]]];
f8vertline[px_, py_, R_, a_, b_] := Line[{{xstarvalue8[px, py, R, a, b],ystarvalue8[px, py, R, a, b]}, {xstarvalue8[px, py, R, a, b], 1000}}]
hstarline8[px_, py_, R_, a_, b_] := Line[{{0, ystarvalue8[px, py, R, a, b]}, {xstarvalue8[px, py, R, a, b], ystarvalue8[px, py, R, a, b]}}]
vstarline8[px_, py_, R_, a_, b_] := Line[{{xstarvalue8[px, py, R, a, b], 0}, {xstarvalue8[px, py, R, a, b], ystarvalue8[px, py, R, a, b]}}]

Manipulate[Plot[{f1[px, py, R], f8[px, py, R, a, b]}, {x, 0, 1000}, PlotRange -> {0, 1000},
Epilog -> {f8vertline[px, py, R, a, b], Red, Dashed, hstarline8[px, py, R, a, b], vstarline8[px, py, R, a, b],
PointSize@Large, Point@opt8[px, py, R, a, b], Text["Optimal Bundle", opt8[px, py, R, a, b], {-1.1, -2}]},
AxesLabel -> {"Good x", "Good y"}, PlotLabel -> "U(x,y)=min{ax,by}", LabelStyle -> Black, ImageSize -> {400, 250}],
{{px, 5}, 0.01, 30, .5, Appearance -> "Labeled"}, {{py, 10}, .01, 30, 0.5, Appearance -> "Labeled"},
{{R, 2500}, 0, 5000, 5, Appearance -> "Labeled"}, {{a, 1}, 0, 25, 5, Appearance -> "Labeled"},
{{b, 1}, 0, 25, 5, Appearance -> "Labeled"},
Button["Reset", {px = 5, py = 10, R = 2500, a = 1, b = 1}], ContentSize -> {500, 300}]


How can I

1.) Replicate the style of the horizontal for the vertical to make it look like one graph;

or

2.) Potentially, use a better strategy to illustrate the contour?

Thank you!

• Please post the code about f1[px, py, R]. Commented Feb 13 at 0:39
• Updated - thank you!
– Tom
Commented Feb 13 at 18:54

Insert ColorData[97, 2] and AbsoluteThickness[1.6] inside Epilog before f8vertline.

So the beginning of Epilog would look like this:

Epilog -> {ColorData[97, 2], AbsoluteThickness[1.6],
f8vertline[px, py, R, a, b], (*continue with the rest of your code*)


Properly styled HalfLine objects would work best in this context. For instance, HalfLine[{x, y}, {1, 0}] would produce a horizontal line segment starting at the point $$(x,y)$$ and continuing to positive infinity. Similarly, HalfLine[{x, y}, {0, 1}] will produce a vertical line segment starting at $$(x,y)$$ and going upwards. See the last entry in the Applications section of the documentation of HalfLine (i.e. "Add droplines to plots").

With[{pt = {1, 2}},
Graphics[
{
{Red,
PointSize[0.02], Point[pt],
Inset[Style["Optimal Bundle", 14], pt, Scaled[{-0.1, -0.3}]],
},
{Orange,
HalfLine[pt, {1, 0}], HalfLine[pt, {0, 1}]
}
},
Axes -> True
]
]
`

• It seems to conflict with Manipulate[Plot[...],Graphics[...]]. Where would you place $Graphics[{Orange, HalfLine[opt8[px, py, R, a, b], {1000, 0}], HalfLine[opt8[px, py, R, a, b], {0, 1000}]}]$ in the above Manipulate section?
– Tom
Commented Feb 13 at 19:09