I have this code to create some DensityPlot
with M12.0.0.0 on Ubuntu
With[{z0 = 1, zm = 1},
lgnds = BarLegend[{{Red, White, Blue}, {-zm, z0}},
Ticks -> {{-zm + (zm/10),
Style[Text[-zm], Black, FontSize -> 14,
FontFamily -> "Latin Modern Roman"]}, {z0,
Style[Text[z0], Black, FontFamily -> "Latin Modern Roman",
FontSize -> 14]}},
LegendMarkerSize -> 140, {LegendLayout -> "Row",
Charting`TickSide -> Right, TicksStyle -> None}];
plot = Legended[
DensityPlot[Sin[x y], {x, -2, 2}, {y, 0, 4},
ColorFunction -> (Blend[{Red, White, Blue},
Rescale[#, {-zm, z0}]] &), PlotPoints -> 80,
FrameStyle -> Black, FrameTicksStyle -> Black, PlotRange -> Full,
AspectRatio -> Full, ImageSize -> Automatic -> {220, 390},
PlotRangeClipping -> False,
ImagePadding -> {{Automatic, Automatic}, {Automatic, 30}},
FrameLabel -> {"", "Y"},
LabelStyle -> {FontFamily -> "Latin Modern Roman", Black,
FontSize -> 16}, GridLines -> {{20.5}, None},
GridLinesStyle -> Directive[Black, Dashed],
ColorFunctionScaling -> False, PlotRangePadding -> None],
Placed[lgnds, {{1, 1}, {1.15, 6.5}}]]]
and this what I see in Mathematica where the BarLegend
is correct
Now, I export this using Export["/home/.../plot.png", plot,ImageResolution -> 500]
and this is what I got:
So, how can I keep the BarLegend
position in the correct place when exporting?
Placed[lgnds, Bottom]
$\endgroup$Bottom
does not do the job. $\endgroup$Placed[lgnds, {{1, 0.86}, {1.15, 6.5}}]
$\endgroup$