I want to put FrameLabel above the axes as it is in case of AxesLabel. Is it possible to control the location of FrameLabel in MMA?

Plot[x, {x, -1, 1}, Frame -> True, FrameLabel -> {"b", "x"}, LabelStyle -> Directive[18]]

enter image description here

If there is an elegant solution that allows to pick the Axes/Frame-label location arbitrarily, please share!


  • 1
    $\begingroup$ Proposed duplicate: (153083) $\endgroup$ – Mr.Wizard Sep 11 '17 at 22:08

You may be able to hack together something with Text. Look up how Scaled, ImageScaled and Offset work for positioning. (The latest version of MaTeX has a short tutorial on these in its documentation: "Preparing Figures to Size".) Make enough room around the frame by setting ImagePadding manually (unfortunately, this is rather inconvenient). Turn off PlotRangeClipping so that elements outside the frame will be rendered (this may be a problem for some plots).

Plot[x, {x, -1, 1}, Frame -> True, PlotTheme -> "Detailed", 
 PlotLegends -> None,

 ImagePadding -> {{30, 5}, {30, 5}},
 PlotRangeClipping -> False, 
 Epilog -> {Text[TraditionalForm[y], 
    Offset[{-20, 0}, Scaled[{0, 1}]], {1, 1}], 
    Offset[{0, -15}, Scaled[{1, 0}]], {1, 1}]}

Mathematica graphics

The default colour of frames/labels is not black, but grey. You may want to figure out what shade it is exactly and match your own labels.

Unfortunately this method is a lot of trouble. If you are going to put this much work into it anyway, take a look at SciDraw. I recommend it for when you are creating publication-quality figures (rather than just a quick visualization).

  • $\begingroup$ I feel that this question is a duplicate of (153083) -- if you agree I think it would be better to move this answer there, or merge the questions which will do that automatically. $\endgroup$ – Mr.Wizard Sep 11 '17 at 22:11
 Plot[x, {x, -1, 1}, Frame -> True, LabelStyle -> Directive[18]],
 {x, b}, {{Top, Left}, {Right, Bottom}}]

enter image description here

  • 2
    $\begingroup$ It is good to know that Labeled is a general notebook object (not Graphics) and will export at 80% size to PDF/EPS. Workaround: stackoverflow.com/q/6093559/695132 $\endgroup$ – Szabolcs Sep 11 '17 at 21:49
 Plot[x, {x, -1, 1}, Frame -> True, 
 FrameLabel -> 
  MapThread[StringJoin[Table["  ", #], #2] &, {{28, 15}, {"x", "y"}}],
  LabelStyle -> Directive[18]]

enter image description here

maybe help , 23333


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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