It has happened to me that when I export certain ContourPlot
outputs, the colours in the legend appear different in the legend. See below the code and the two pictures (on the left the notebook file, on the right the exported pdf). What is happening?
ρ[x_, y_] := Sqrt[x^2 + y^2];
Θ[x_, y_] := ArcTan[x, y];
f[x_, y_, t_] :=
Piecewise[{{1/2 +
0.000051502449550377714*t*BesselK[0, Sqrt[x^2 + y^2]/10] -
BesselK[0,
Sqrt[x^2 + y^2]/10]/(2*
BesselK[0, 1/10]) + ((0.5 - 0.00012500000000000003*t)*
BesselK[1, Sqrt[x^2 + y^2]/10]*Cos[0. + ArcTan[x, y]])/(2*
BesselK[1, 1/10]),
x^2 + y^2 >=
1}, {((0.5 - 0.00012500000000000003*t)*
BesselJ[1, Sqrt[x^2 + y^2]/10]*Cos[0. + ArcTan[x, y]])/(2*
BesselJ[1, 1/10]), 0 < x^2 + y^2 < 1}}, 0];
g[x_, y_, t_] :=
Piecewise[{{((0.5 - 0.0025000000000000005*t)*
Sin[0. + ArcTan[x, y]])/(2*Sqrt[x^2 + y^2]),
x^2 + y^2 >=
1}, {((0.5 - 0.0025000000000000005*t)*Sqrt[x^2 + y^2]*
Sin[0. + ArcTan[x, y]])/2, 0 < x^2 + y^2 < 1}}, 0];
x0=0;L=1;a=1;Ly=L;y0=0;
cs2[t_] := ContourPlot[(2 f[x, y, t]^2 +
2 g[ρ[x, y], Θ[x, y], t]^2)^(1/2), {x, -L + x0, L + x0}, {y, -L + y0, L + y0}, PlotLegends -> Automatic, PlotRange -> {Full, Full, {0, 0.5}}, PlotPoints -> 30, ColorFunction -> ({Opacity[0.6], ColorData["TemperatureMap"][#]} &), Contours -> 100, RegionFunction -> Function[{x, y}, 0.01 < x^2 + y^2 < a^2], Exclusions -> None];
Export["inner.pdf",cs2[0]]
y0
defined, but based on your plot range in the images I set it to the same value as x0. $\endgroup$ContourPlot[Sin[x + y], {x, -3, 3}, {y, -3, 3}.....
- it makes it easier to nail down what is happening if we can use a simpler example. Also, what happens if you use(Directive[Opacity[0.5], ColorData["TemperatureMap"][#]] &)
for yourColorFunction
instead? $\endgroup$cs2 = ContourPlot[x + y^2, {x, -3, 3}, {y, -3, 3}, PlotLegends -> Automatic, PlotRange -> {Full, Full, {0, 0.5}}, PlotPoints -> 30, ColorFunction -> (Directive[Opacity[0.5], ColorData["TemperatureMap"][#]] &), Contours -> 100, RegionFunction -> Function[{x, y}, 0.01 < x^2 + y^2 < a^2], Exclusions -> None, ImageSize -> Large];
$\endgroup$