1
$\begingroup$

I'm trying to plot $\sin(x)/x$ and fill the positive side. How do I achieve that? I know how to fill the entire axis. Here's what I have:

Show[Plot[Sin[x]/x, {x, -2 π, 2 π}, Filling -> Axis], 
 AxesLabel -> {HoldForm[Distance from Slit], HoldForm[Amplitude]}, 
 PlotLabel -> HoldForm[Single Slit Difraction]]
$\endgroup$
0

2 Answers 2

3
$\begingroup$
Show[
 Plot[Sin[x]/x, {x, -2 π, 2 π}],
 Plot[Sin[x]/x, {x, 0, 2 π}, Filling -> Axis], 
 AxesLabel -> {"Distance from Slit", "Amplitude"},
 PlotLabel -> "Single Slit Difraction\n"]

enter image description here

$\endgroup$
3
$\begingroup$
Plot[
 Sin[x]/x
 , {x, -2 π, 2 π}
 , Filling -> {1 -> {Axis, {Transparent, Automatic}}}
 , AxesLabel -> {"Distance from Slit", "Amplitude"}
 , PlotLabel -> "Single Slit Difraction"
 ]

Mathematica graphics

OR

Plot[
 Sin[x]/x
 , {x, -2 π, 2 π}
 , Filling -> Axis
 , FillingStyle -> {Transparent, LightBlue}
 , AxesLabel -> {"Distance from Slit", "Amplitude"}
 , PlotLabel -> "Single Slit Difraction"
 ]

Mathematica graphics

Documentation for Filling

Mathematica graphics

$\endgroup$

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