This compares two curves, with a slider to control one parameter:
k = 8.617 10^-5; (*eV/K*)
nFD[ϵ_, μ_, t_] := 1/(E^((ϵ - μ)/(k t)) + 1);
g[ϵ_] := Sqrt[ϵ];
Manipulate[
Plot[{g[ϵ],
g[ϵ]*nFD[ϵ, 1, t]}, {ϵ, 0, 2},
PlotRange -> {{0, 2}, {0, 1.5}},
GridLines -> {{1.0}, None},
GridLinesStyle -> Directive[Dotted, Gray],
AxesLabel -> {"ϵ",
"\!\(\*SubscriptBox[OverscriptBox[\(n\), \(_\)], \(FD\)]\)"},
Filling -> {1 -> {2}, 2 -> Axis},
Ticks -> {{{1, "μ"}}, Automatic},
PlotLegends ->
Placed[{"g[ϵ]",
"g[ϵ]*\!\(\*SubscriptBox[OverscriptBox[\(n\), \(_\)], \
\(FD\)]\)[ϵ]"}, {{0.05, 0.98}, {0, 1}}]
], {{t, 1}, 1, 10^4}]
It works fine, except for one glitch: When the slider is all the way to the left, or almost all the way, both functions get cut off slightly to the right of the vertical dotted line, even though the x-axis continues farther. (Sometimes I have to move the slider right then left again to trigger it.) Here's a screen shot:
For slightly larger slider values, the functions appear properly drawn all the way to the right edge of the plot:
I have been unable to figure out why, or to find a workaround. Any thoughts, o sage ones?
plot[t_] := Plot[{g[\[Epsilon]], g[\[Epsilon]]*nFD[\[Epsilon], 1, t]}, {\[Epsilon], 0, 2}, PlotRange -> {{0, 2}, {0, 1.5}}]
, the problem can be seen onplot[4]
for example. Strangely enough, if you removeg[\[Epsilon]]*Chop@nFD[\[Epsilon], 1, t]
, the blue curve becomes normal. $\endgroup$Show
is a possible workaround, but it makes niceties like legends and filling between curves much more awkward to manage. $\endgroup$Chop
. I don't have time to edit the post right now, but will try to do that soon. Thanks. $\endgroup$