2
$\begingroup$

I would like to create a filling delineated by the plots and lines as specified below:

f[x_] := x

f2[x_] := x - (1/6)

f3[x_] := x + (1/6)

line1 = Line[{{10, 0}, {10, 10}}];

line2 = Line[{{0, 10}, {10, 10}}];

line3 = Line[{{9, 9}, {10, 9}}];

lineStyle = {Thick, Black, Dashed};

Plot[{f[x], f2[x], f3[x]}, {x, 9, 10}, 
 Epilog -> {Directive[lineStyle], line1, line2, line3}]

I suppose a better way would probably be to transform the vertical lines into actual plots somehow. Any help?

Thanks.

$\endgroup$

2 Answers 2

5
$\begingroup$

It is not clear how you want the filling done. Here is one filling.

f[x_] := x
f2[x_] := x - (1/6)
f3[x_] := x + (1/6)

line1 = Line[{{10, 0}, {10, 10}}];
line2 = Line[{{0, 10}, {10, 10}}];
line3 = Line[{{9, 9}, {10, 9}}];

lineStyle = {Thick, Black, Dashed};

Plot[{f[x], f2[x], f3[x]}, {x, 9, 10}, 
 Epilog -> {Directive[lineStyle], line1, line2, line3},
 Filling -> {
   3 -> {10, {LightGreen, Darker[Green]}},
   2 -> {9, {Darker[Orange], LightOrange}}}]

enter image description here

$\endgroup$
4
$\begingroup$

Also

Plot[{9, 10, f1[x], f2[x], f3[x]}, {x, 9, 10}, 
 Epilog -> {Directive[lineStyle], line1, line2, line3}, 
 Filling -> {{5 -> {{2}, {Blue, Green}}}, {4 -> {{1}, {Red, Orange}}}}, 
 BaseStyle -> Thick]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.