Is there an option to change the space/distance between tick labels and axes labels for plots?
The most convenient way I found is to wrap Plot
(without FrameLabels
and PlotLabel
and with appropriate ImagePadding
and ImageMargins
) inside Labeled
and use the Spacings
option to position the labels:
Labeled[Plot[Sin[x], {x, -Pi, Pi}, Frame -> True,
ImagePadding -> {{20, 1}, {15, 2}}, ImageMargins -> 0,
FrameTicksStyle -> 10, RotateLabel -> False],
TraditionalForm /@ {Sin[x], x, Row[{"This is a plot of ", Sin[x]}]},
{Left, Bottom, Top},
Spacings -> {0, 0}, LabelStyle -> "Panel"]
This can also be achieved by
- encasing the graphic inside a
Show
, - setting the outer
Show
'sPlotRangeClipping
toFalse
, and - adding the labels as
Text
commands inside anEpilog
.
Thus, for your example, you would do
Framed[
Show[
Plot[Sin[x], {x, -Pi, Pi}
, Frame -> True
, FrameLabel -> {{None, None}, {None,
Row[{"This is a plot of ", Sin[x]}]}}
, ImagePadding -> {{55, 10}, {35, 20}}
, ImageMargins -> 0
, FrameTicksStyle -> 10
, RotateLabel -> False
]
, PlotRangeClipping -> False
, Epilog -> {
Text[x, {0, -1.4}],
Text[Sin[x], {-4.12, 0}]
}
]
, FrameMargins -> 0
]
which produces
You can then freely place the label text anywhere within the image box by adjusting the Text
coordinates.
This has the advantage that (as far as I can tell, on v10.1.0) the resulting styling is identical to that produced by setting the labels via AxesLabel
or FrameLabel
; if you want to style them directly then you can do that as well.
Further, this produces an actual Graphics
object, as opposed to an object with a Labeled
head, which can be advantageous for manipulating and exporting the resulting plot.
Due credit to David Park's answer on this comp.soft-sys.math.mathematica thread for pointing out the technique.
When using SciDraw, we have full control over all label positions. The key option names are variation on TextNudge
. The value specified in this option will be added to the label position.
Example with frame labels:
Figure[
{
FigurePanel[{}, FrameLabel -> {x, y},
XFrameTextNudge -> 10, (* shift up by 10 pt *)
YFrameTextNudge -> {10, 0} (* shift right by 10 pt *)
]
}
]
SciDraw of course draws its own frames and requires working in (and learning) its own framework. It will not help in changing the position of standard frame labels.
The ability of SciDraw to move labels is one of the several reasons why I usually use it for publication figures. I you have the time and are willing to learn it, it is a good option to deal with the label positioning problem.