# Avoid errors in StreamDensityPlot and StreamPlot/DensityPlot?

GROUPS:
 I am trying to plot the electric field intensity and vector directionality of a simple line charge. I tried plotting with StreamDensityPlot, however, the intensity (that is, the density component of the StreamDensityPlot) comes back as single color, while the stream lines are faint and difficult to see. I have tried changing the color of the density map and the streamlines but nothing changes the fact that the density plot comes back as a single uniform color. Is this a glitch with StreamDensityPlot? Here is the code that generates the electric field of the line charge: ClearAll; (* Constants *) qe = 1.6023*(10^-19) (* [C] *); hbar = 1.055*(10^-34) (* [J s] *); me = 9.109*(10^-31) (* [J s^2 m^-2] *); \[Epsilon]0 = 8.854*(10^-12) (* [C V^-1] *); ke = (4*\[Pi]*\[Epsilon]0)^-1 (* [V C^-1] *); (* Electric Fields: Theory *) Fprimex[x_, y_, z_, \[Lambda]_, L_] = ke*(x*\[Lambda])/(x^2 + y^2 + (z - zprime)^2)^(3/2); Fprimey[x_, y_, z_, \[Lambda]_, L_] = ke*(y*\[Lambda])/(x^2 + y^2 + (z - zprime)^2)^(3/2); Fprimez[x_, y_, z_, \[Lambda]_, L_] = ke*((z - zprime)*\[Lambda])/(x^2 + y^2 + (z - zprime)^2)^(3/2); Fx[x_, y_, z_, \[Lambda]_, L_] = Integrate[ Fprimex[x, y, z, \[Lambda], L], {zprime, -(L/2), L/2}, Assumptions -> { -(L/2) <= zprime <= L/2, \[Epsilon] > 0, L > 0, x \[Element] Reals, y \[Element] Reals, z > Abs[L/2], \[Lambda] \[Element] Reals } ]; Fy[x_, y_, z_, \[Lambda]_, L_] = Integrate[ Fprimey[x, y, z, \[Lambda], L], {zprime, -(L/2), L/2}, Assumptions -> { -(L/2) <= zprime <= L/2, \[Epsilon] > 0, L > 0, x \[Element] Reals, y \[Element] Reals, z > Abs[L/2], \[Lambda] \[Element] Reals } ]; Fz[x_, y_, z_, \[Lambda]_, L_] = Integrate[ Fprimez[x, y, z, \[Lambda], L], {zprime, -(L/2), L/2}, Assumptions -> { -(L/2) <= zprime <= L/2, \[Epsilon] > 0, L > 0, x \[Element] Reals, y \[Element] Reals, z > Abs[L/2], \[Lambda] \[Element] Reals } ]; (* Longitudinal Electric Field *) Ez[\[Rho]_, z_, \[Lambda]_, L_] = Simplify[ Fz[x, y, z, \[Lambda], L] /. { x -> \[Rho]*Cos[\[Phi]], y -> \[Rho]*Sin[\[Phi]] } ]; (* Radial Electric Field *) E\[Rho][\[Rho]_, z_, \[Lambda]_, L_] = Simplify[ Sqrt[Fx[x, y, z, \[Lambda], L]^2 + Fy[x, y, z, \[Lambda], L]^2] /. { x -> \[Rho]*Cos[\[Phi]], y -> \[Rho]*Sin[\[Phi]] } ]; Here is the StreamDensityPlot code: Manipulate[ Show[ (* Probabilities *) StreamDensityPlot[ { Evaluate[ E\[Rho][\[Rho], z, \[Lambda], L] ], Evaluate[ Ez[\[Rho], z, \[Lambda], L] ] }, { \[Rho], 10^-12, R }, { z, -Z, Z }, PlotRange -> { {-R, R}, {-Z, Z} }, ImageSize -> Large, Frame -> True, FrameLabel -> { Style["Radial Position [cm]", 20, FontFamily -> "Times"], Style["Longitudinal Position [cm]", 20, FontFamily -> "Times"] }, BaseStyle -> {FontFamily -> "Times", FontSize -> 20}, AxesOrigin -> {0, 0}, Axes -> True, PerformanceGoal -> "Quality", ColorFunction -> "TemperatureMap", StreamColorFunction -> Directive[ RGBColor[1, 1, 1] ], MaxRecursion -> 4 ], StreamDensityPlot[ { -E\[Rho][\[Rho], z, \[Lambda], L], Ez[\[Rho], z, \[Lambda], L] }, { \[Rho], -R, -10^-12 }, { z, -Z, Z }, PlotRange -> { {-R, -10^-12}, {-Z, Z} }, ColorFunction -> "TemperatureMap" ], Graphics[{ { AbsoluteThickness[7], RGBColor[1, 0, 0], Opacity[0.95], Line[{{0, -L/2}, {0, L/2}}] } (* Graphics *)}] (* Show *)], "", (* Function Parameters *) "", Style["Linear Charge Density", Bold, 12, FontFamily -> "Times"], {{\[Lambda], 5*10^-9, Style["\[Lambda] [\!$$\*FractionBox[\(C$$, $$cm$$]\)]", FontSize -> 16, FontFamily -> "Times"]}, 0.1*10^-9, 10*10^-9, 0.1*10^-9, ControlType -> {Slider, PopupMenu}, ImageSize -> Medium, Appearance -> "Labeled"}, "", Style["Charge Length", Bold, FontSize -> 14, FontFamily -> "Times"], {{L, 1, Style["L [cm]", FontSize -> 16, FontFamily -> "Times"]}, 0.1, 100, ControlType -> {Slider, PopupMenu}, ImageSize -> Medium, Appearance -> "Labeled" }, "", "", (* Axes *) "", "", {{R, 1, Style["\!$$\*SubscriptBox[\(\[Rho]$$, $$max$$]\)", FontSize -> 16, FontFamily -> "Times"]}, 0.000001, 2, ControlType -> {Slider, PopupMenu}, ImageSize -> Medium, Appearance -> "Labeled" }, {{Z, 1, Style["\!$$\*SubscriptBox[\(z$$, $$max$$]\)", FontSize -> 16, FontFamily -> "Times"]}, 0.000001, 2, ControlType -> {Slider, PopupMenu}, ImageSize -> Medium, Appearance -> "Labeled" }, ControlPlacement -> Left, SaveDefinitions -> False, TrackedSymbols :> {\[Lambda], L, R, Z} (* Manipulate *)] One work-around I've noticed somewhat works is to use DensityPlot and StreamPlot separately, connected with Show[]. However, this also produces a gltich. While the density plot shows contours now, there is a large white area near the line charge that cannot be plotted. I have tried adjusting EVERYTHING in the DensityPlot but nothing gets rid of the white blob in the center of the plot.Show[ DensityPlot[], StreamPlot[] ] code here: Manipulate[ Show[ (* Probabilities *) StreamDensityPlot[ { }, { \[Rho], -R, R }, { z, -Z, Z }, PlotRange -> { {-R, R}, {-Z, Z} }, ImageSize -> Large, Frame -> True, FrameLabel -> { Style["Radial Position [cm]", 20, FontFamily -> "Times"], Style["Longitudinal Position [cm]", 20, FontFamily -> "Times"] }, BaseStyle -> {FontFamily -> "Times", FontSize -> 20}, AxesOrigin -> {0, 0}, Axes -> True ], DensityPlot[ { E\[Rho][\[Rho], z, \[Lambda], L], Ez[\[Rho], z, \[Lambda], L] }, { \[Rho], 10^-12, R }, { z, -Z, Z }, PlotRange -> { {10^-12, R}, {-Z, Z} }, PlotLegends -> Placed[ BarLegend[ Automatic, LegendLabel -> Style["Electric Field [V \!$$\*SuperscriptBox[\(cm$$, \ $$-1$$]\)]", 20, FontFamily -> "Times"], LabelStyle -> {FontSize -> 20}, TicksStyle -> {FontFamily -> "Times"} ], Right], ColorFunction -> "TemperatureMap" ], StreamPlot[ { E\[Rho][\[Rho], z, \[Lambda], L], Ez[\[Rho], z, \[Lambda], L] }, { \[Rho], 10^-12, R }, { z, -Z, Z }, PlotRange -> { {10^-12, R}, {-Z, Z} }, (* StreamPoints\[Rule]20, *) StreamStyle -> Directive[RGBColor[0, 0, 0], AbsoluteThickness[1], Dashed, Opacity[0.5]] ], DensityPlot[ { E\[Rho][\[Rho], z, \[Lambda], L], Ez[\[Rho], z, \[Lambda], L] }, { \[Rho], -R, -10^-12 }, { z, -Z, Z }, PlotRange -> { {-R, -10^-12}, {-Z, Z} }, ColorFunction -> "TemperatureMap" ], StreamPlot[ { -E\[Rho][\[Rho], z, \[Lambda], L], Ez[\[Rho], z, \[Lambda], L] }, { \[Rho], -R, -10^-12 }, { z, -Z, Z }, PlotRange -> { {-R, -10^-12}, {-Z, Z} }, (* StreamPoints\[Rule]20, *) StreamStyle -> Directive[RGBColor[0, 0, 0], AbsoluteThickness[1], Dashed, Opacity[0.5]] (* ColorFunction\[Rule]"" *) ], Graphics[{ { AbsoluteThickness[7], RGBColor[1, 0, 0], Opacity[0.95], Line[{{0, -L/2}, {0, L/2}}] } (* Graphics *)}] (* Show *)], "", (* Function Parameters *) "", Style["Linear Charge Density", Bold, 12, FontFamily -> "Times"], {{\[Lambda], 5*10^-9, Style["\[Lambda] [\!$$\*FractionBox[\(C$$, $$cm$$]\)]", FontSize -> 16, FontFamily -> "Times"]}, 0.1*10^-9, 10*10^-9, 0.1*10^-9, ControlType -> {Slider, PopupMenu}, ImageSize -> Medium, Appearance -> "Labeled"}, "", Style["Charge Length", Bold, FontSize -> 14, FontFamily -> "Times"], {{L, 1, Style["L [cm]", FontSize -> 16, FontFamily -> "Times"]}, 0.1, 100, ControlType -> {Slider, PopupMenu}, ImageSize -> Medium, Appearance -> "Labeled" }, "", "", (* Axes *) "", "", {{R, 1, Style["\!$$\*SubscriptBox[\(\[Rho]$$, $$max$$]\)", FontSize -> 16, FontFamily -> "Times"]}, 0.000001, 2, ControlType -> {Slider, PopupMenu}, ImageSize -> Medium, Appearance -> "Labeled" }, {{Z, 1, Style["\!$$\*SubscriptBox[\(z$$, $$max$$]\)", FontSize -> 16, FontFamily -> "Times"]}, 0.000001, 2, ControlType -> {Slider, PopupMenu}, ImageSize -> Medium, Appearance -> "Labeled" }, ControlPlacement -> Left, SaveDefinitions -> False, TrackedSymbols :> {\[Lambda], L, R, Z} (* Manipulate *)] Does anyone have ANY experience using StreamDensityPlot or DensityPlot with StreamPlot? I cannot figure out why neither one of them is working. Tim