# Weird discrepancy in Density Plot

I have the following long Lorentzian function that I have made to be dependent on three parameters (ω,κ2,g2):

s[ω_, κ2_, g2_] := (64 g1^2 g2^2 (0.5 + n2) Sqrt[κ2^2])/(16 g2^4 (Γ^2 + 4 ω^2) + (κ2^2 + 4 ω^2) (16 g1^4 + 8 g1^2 (Γ κ1 - 4 ω^2) + (Γ^2 + 4 ω^2) (κ1^2 + 4 ω^2)) + 8 g2^2 ((κ1 κ2 - 4 ω^2) (Γ^2 + 4 ω^2) + 4 g1^2 (Γ κ2 + 4 ω^2))) + (16 g1^2 (0.5 + n1) Sqrt[κ1^2] (κ2^2 + 4 ω^2))/(16 g2^4 (Γ^2 + 4 ω^2) + (κ2^2 + 4 ω^2) (16 g1^4 + 8 g1^2 (Γ κ1 - 4 ω^2) + (Γ^2 + 4 ω^2) (κ1^2 + 4 ω^2)) + 8 g2^2 ((κ1 κ2 - 4 ω^2) (Γ^2 + 4 ω^2) + 4 g1^2 (Γ κ2 + 4 ω^2))) + (4 (0.5 + nm) Γ (16 g2^4 + 8 g2^2 (κ1 κ2 - 4 ω^2) + (κ1^2 + 4 ω^2) (κ2^2 + 4 ω^2)))/(16 g2^4 (Γ^2 + 4 ω^2) + (κ2^2 + 4 ω^2) (16 g1^4 + 8 g1^2 (Γ κ1 - 4 ω^2) + (Γ^2 + 4 ω^2) (κ1^2 + 4 ω^2)) + 8 g2^2 ((κ1 κ2 - 4 ω^2) (Γ^2 + 4 ω^2) + 4 g1^2 (Γ κ2 + 4 ω^2)))


Plotting s as a function of ω (with other fixed parameters):

Plot[(s[ω, 20, 1] /. {g1 -> 5, κ1 -> 1, Γ -> 1/100, nm -> 300, n1 -> 0.1, n2 -> 0.1}), {ω, -15, 15}, ImageSize -> Automatic, PlotLabel -> {"sbb"}, PlotRange -> All]


Returns:

Which is fine. However, I intend to study the behavior of the function as g1 is varied. So I make the following density plot:

DensityPlot[(s[ω, 20, 1] /. {κ1 -> 1, Γ -> 1/100, nm -> 300, n1 -> 0.1, n2 -> 0.1}), {g1, 0, 10}, {ω, -15, 15}, PlotRange -> All, PlotLegends -> Automatic, WorkingPrecision -> 20, PlotPoints -> 100, PlotRangePadding -> None, ColorFunction -> "Rainbow", ImageSize -> Medium]


But I'm returned with:

Which make no sense since I should see intensity on the y-axis (ω) at ω = 5 and ω = -5 as evident in the 2-D plot above (they both were plotted with the same parameters, I'm just varying g1). What is going on here? Why is the density plot not showing?

Edit: I decided to set my PlotRange finitely. Instead of PlotRange -> All, I do PlotRange -> {{0,10},{-15,15}} (to match my plotting range under DensityPlot) and I arrive with:

What's going on here? Why are there white spaces?

Whatever is higher than you plot range will be clipped - that is the white spaces. As you did not specify PlotRange for z value Mathematica clipped it automatically at some low value and everything above is a white space. Before when you specified PlotRange -> All it showed all values including very high ones so very low values - most of the plot - were indistinguishable and showed as a uniform background. Read docs on PlotRange for proper specs for 3D cases and maybe also read on ClippingStyle.

Your function has very high values at the origin:

Limit[s[0, 20, 1] /. {κ1 -> 1, Γ -> 1/100, nm -> 300, n1 -> 0.1, n2 -> 0.1}, g1 -> 0]


120199.99999999999

So you cannot see everything - seeing high values will make low values invisible. So you need to clip at right value to see most of the behavior:

Plot3D[s[ω, 20,
1] /. {κ1 -> 1, Γ -> 1/100, nm -> 300,
n1 -> 0.1, n2 -> 0.1}, {g1, 0, 10}, {ω, -15, 15},
PlotLegends -> Automatic, PlotPoints -> 100,
ColorFunction -> "Rainbow", PlotRange -> {0, 20}]


DensityPlot[
s[ω, 20, 1] /. {κ1 -> 1, Γ -> 1/100,
nm -> 300, n1 -> 0.1, n2 -> 0.1}, {g1, 0, 10}, {ω, -15, 15},
PlotLegends -> Automatic, WorkingPrecision -> 20, PlotPoints -> 100,
PlotRangePadding -> None, ColorFunction -> "Rainbow",
PlotRange -> {0, 20}]


Another trick is to log-scale the vertical z-axis:

DensityPlot[
s[ω, 20, 1] /. {κ1 -> 1, Γ -> 1/100,
nm -> 300, n1 -> 0.1, n2 -> 0.1}, {g1, 0, 10}, {ω, -15, 15},
PlotLegends -> Automatic, PlotPoints -> 100,
PlotRangePadding -> None, ColorFunction -> "Rainbow",
PlotRange -> All, ScalingFunctions -> "Log"]