Is there a way to make the barlegend in a density or contour plot the same width/ height as the plot, depending on if you position the barlegend above or after the plot? The only related post that I found was this one here, and it is over 5 years old.
1 Answer
$\begingroup$
$\endgroup$
1
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
ImageSize -> {300, 300},
PlotLegends -> BarLegend[Automatic, LegendMarkerSize -> {100, 300}]]
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
ImageSize -> {300, 300},
PlotLegends -> BarLegend[Automatic, LegendMarkerSize -> {300, 300}]]
Edit:
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
ImageSize -> {300, 300},
PlotLegends ->
Placed[BarLegend[Automatic, LegendLayout -> "Row",
LegendMarkerSize -> {300, 100}], Above]]
-
$\begingroup$ Btw, do you know if it is possible to change the appearance of the legend, as you did, and have it placed above the plot? $\endgroup$ Commented Mar 2, 2018 at 8:04