How can I plot a curve with a filled sub-domain as shown below?
Asked
Active
Viewed 108 times
0
m_goldberg
- 107,779
- 16
- 103
- 257
user45951
- 27
- 3
1 Answers
3
Let f be the function to plot. Define a 2nd function, g that restricts f to the given sub-domain. Use the fill option Filling -> 2 -> Axis.
f[x_] := 1/x^2
g[x_] := Piecewise[{{f[x], 3/2 <= x <= 2}}, Null]
Plot[{f[x], g[x]}, {x, 1, 4},
Filling -> 2 -> Axis,
PlotRange -> {0, Automatic}]
m_goldberg
- 107,779
- 16
- 103
- 257
-
-
@user45951. I'm glad you find my answer useful. Please consider accepting it. You can do that by clicking on the check mark that appears on the left of the answer below the down arrow. – m_goldberg Sep 10 '17 at 01:27


Plots with a different V range, useFillingin one, combine them withShow. What have you tried so far? Did you look at thePlotdocumentation? – Szabolcs Sep 09 '17 at 14:24