1

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.

Turbotanten
  • 691
  • 5
  • 18

1 Answers1

2
  DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}, 
 ImageSize -> {300, 300}, 
 PlotLegends -> BarLegend[Automatic, LegendMarkerSize -> {100, 300}]] 

enter image description here

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

enter image description here

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]]

enter image description here

OkkesDulgerci
  • 10,716
  • 1
  • 19
  • 38
  • 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? – Turbotanten Mar 02 '18 at 08:04