2
$\begingroup$

I would like to add the label "Omega" on top of the lateral bar in my density plot, like this (I did it using paint):

Example of density plot

I spent hours on the documentation, but I didn't find how to obtain such a trivial thing...

$\endgroup$
2
  • 4
    $\begingroup$ Use the option PlotLegends -> BarLegend[Automatic, LegendLabel -> "Omega"]? $\endgroup$
    – kglr
    Dec 30, 2022 at 15:53
  • 1
    $\begingroup$ DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3} , ColorFunction -> "Rainbow" , PlotLegends -> Placed[BarLegend[{"Rainbow", {0, 3}} , LegendLabel -> Style["Omega", Bold, 12]] , {1.05, 0.5} ] ] $\endgroup$
    – Syed
    Dec 30, 2022 at 15:53

1 Answer 1

4
$\begingroup$
Clear["Global`*"]

Explicitly specify the PlotLegend as a BarLegend then you can use the option LegendLabel

DensityPlot[Sin[x] Sin[y],
 {x, -4, 4}, {y, -3, 3},
 PlotLegends -> BarLegend[Automatic, LegendLabel -> "Omega"]]

enter image description here

$\endgroup$

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