4
$\begingroup$

How can I have the barlegend positioned above the plot instead of to the right of the plot? I know there is a place command that is given by

Plotlegends -> Placed[Automatic,Above],

But I don't know how to combine barlegend with placed?

DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
 ImageSize -> {400, 300},
 PlotLegends -> BarLegend[Automatic, LegendMarkerSize -> {40, 300}],
 AspectRatio -> Automatic]

**

Example of when I try to combine BarLegend with Placed

DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
 ImageSize -> {400, 300},
 PlotLegends -> {BarLegend[Automatic, LegendMarkerSize -> {40, 300}], 
   Placed[Automatic, Above]},
 AspectRatio -> Automatic]

enter image description here

As you can see I now have two barlegends with one of them being the same size as the plot.

$\endgroup$

1 Answer 1

4
$\begingroup$
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}, 
 ImageSize -> {400, 300}, AspectRatio -> Automatic, 
 PlotLegends -> 
  Placed[BarLegend[Automatic, LegendMargins -> {{0, 0}, {10, 5}}, 
    LegendMarkerSize -> {400, 40}, LegendLabel -> "legend", 
    LabelStyle -> {FontFamily -> "Calibri", FontSize -> 10}], Above]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.