# How to explicitly assign the position in Labeled[]?

From the documentation, Labeled accepts the positions 'Top, Bottom, Right, Left'. But this is too vague in some situations. So my question is whether it's possible to give the explicit position of labeling object respect to the labeled one?

A minimal example will be

Labeled[DensityPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1},
PlotLegends -> BarLegend[{Automatic, {0, 2}}]], {"a", "b"}, {Bottom,
Top}]


Let's say I want to put the label "b" at 3/4 to the left. I hope I could assign the position and alignment like {Top,Scaled[.75]}. What should I do?(Please do not use FrameLabel because the labeled object doesn't have to be a 'plot'. I just use it as an example here.) A very dumb workaround that I can think of is to add extra space before but that's just too ugly.

What I want to achieve:

## 2 Answers

You can have finer control on positioning if you use Legended in stead of Labeled:

Legended[DensityPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1},
PlotLegends -> BarLegend[{Automatic, {0, 2}}]],
{Placed["a", Bottom], Placed["b", {{.85, 1.02}}]}]


You could use Show to combined graphics, including text.

Positions can be specified with scaled coordinates (relative to the plot):

Show[
DensityPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1},
PlotLegends -> BarLegend[{Automatic, {0, 2}}]],
Graphics[{
Text[Style["b", Medium], Scaled[{.75, 1.05}]],
Text[Style["a", Medium], Scaled[{.5, -.08}]]
}], ImagePadding -> 30, PlotRangeClipping -> False, ImageSize -> 300]


Or with absolute coordinates:

Show[
DensityPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1},
PlotLegends -> BarLegend[{Automatic, {0, 2}}]],
Graphics[{
Text[Style["b", Medium], {0.5, 1.15}],
Text[Style["a", Medium], {0, -1.2}]
}], ImagePadding -> 30, PlotRangeClipping -> False, ImageSize -> 300]


ImagePadding may need to be adjusted to make room for the labels.