1

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]]
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Ccyan
  • 239
  • 2
  • 8

2 Answers2

3
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

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
3
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

rhermans
  • 36,518
  • 4
  • 57
  • 149