2
$\begingroup$

I am plotting different waves (computed numerically and analytically) and, for that, I have used the following code:

Plot[Sin[t], {t, 0, 50}, PlotStyle -> Red, Axes -> False, Frame -> True, PlotTheme -> "Classic", FrameLabel -> {"t", "\[Phi] (0, t)"}, FrameStyle -> Directive[Black, 25], 
 PlotLegends -> Placed[{"Exact."}, {{1, 0.56}}], PlotLabel -> Style[Framed["w = 1, k = 0", 
 RoundingRadius -> 5], 20, Black, Background -> Lighter[White]]

what gives:

enter image description here

As you can notice, the frame that contains some specifications is not centered. How can I place it in the correct position (centered)? I have attempted to use the Placed instruction but it doesn't work (or I've not been able to write properly the instruction).

$\endgroup$

2 Answers 2

3
$\begingroup$

One possibility is to use Labeled:

Labeled[
 Plot[Sin[t]
  , {t, 0, 50}
  , PlotStyle -> Red
  , Axes -> False
  , Frame -> True
  , PlotTheme -> "Classic"
  , FrameLabel -> {"t", "\[Phi] (0, t)"}
  , FrameStyle -> Directive[Black, 16]
  , PlotLegends -> Placed[{"Exact."}, {{1, 0.56}}]
  ]
 , Framed[
  Style["w = 1, k = 0", 20, Black]
  , FrameStyle -> {Black, AbsoluteThickness[1.2]}
  , RoundingRadius -> 5
  , Background -> Lighter[White]
  ]
 , Top
 ]

enter image description here

$\endgroup$
3
$\begingroup$

use FrameLabel since you set Frame to True. You were using FrameLabel And also using PlotLabel. Why mix the two? FrameLabel can do all of these. The top frame label now acts as the overall Plot Label.

FrameLabel is also automatically centered on each edge.

Mathematica graphics

Plot[Sin[t], {t, 0, 50},
 PlotStyle -> Red,
 Axes -> False,
 Frame -> True,
 PlotTheme -> "Classic",
 FrameStyle -> Directive[Black, 25],
 PlotLegends -> Placed[{"Exact."}, {{1, 0.56}}],
 FrameLabel -> {{"ϕ (0, t)", Automatic}, {"t", 
    Style[Framed["w = 1, k = 0", RoundingRadius -> 5], 20, Black, 
     Background -> Lighter[White]]}},
 ImageSize -> 500
 ]
$\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.