I am producing some plots with legends on Mathematica, using PlotLegends
.
For aesthetical reasons, I was wondering if there was a simple way to impose to a legend placed above a plot to be horizontally centered with respect to the plot's frame. The default behaviour seems rather to have it horizontally centerd with respect to the full figure (which includes axes labels), which can sometimes induce a visual feeling of ill-alignment.
Here is an exagerated example of the behaviour that I am trying to avoid :
P1 = Plot[{Sin[3 \[Theta] + 1], Cos[\[Theta]]}, {\[Theta], 0, 2 \[Pi]}, Frame -> True,
FrameTicksStyle -> Directive[FontSize -> 16],
PlotLegends -> Placed["Expressions", {Center, Above}],
FrameLabel -> {Style["\[Theta]", 25], Style["|\[CapitalPsi]|", 25]}]
with outcome
The legends are not centered with respect to the frame, but with respect to the frame+labels of the axes, which makes them appear too much left with respect to the frame.
The centering result that I would seek for the same example is that of PlotLabel
, which centers the text with respect to the frame:
P2 = Plot[{Sin[3 \[Theta] + 1], Cos[\[Theta]]}, {\[Theta], 0, 2 \[Pi]}, Frame -> True,
FrameTicksStyle -> Directive[FontSize -> 16],
PlotLabel -> "--- sin(3\[Theta]+1) --- cos(\[Theta])",
FrameLabel -> {Style["\[Theta]", 25], Style["|\[CapitalPsi]|", 25]}]
with outcome
Obviously PlotLabel
is not suitable for legending, but I am looking for a legending option that offers a final legend alignment similar to it.