0
$\begingroup$

This question is almost as old as plotting in mathematica goes. How can one change the spacing between the numbers on the frame of a plot and the framelabel?

Example:

Plot[Sin[x], {x, -1, 1}, Frame -> True, FrameLabel -> {"x", "sin(x)"}, LabelStyle -> {Black, FontSize -> 15}]

I want to change the distance shown with the two black lines: enter image description here

Now comes the hard part:

  1. I dont want use Labeled for multiple reasons. This is the most common answer to this question.
  2. I want to make the distance smaller! If I would want to make it larger, I could just wrap it inside of a Pane.

I am using Mathematica such a long time that I cannot believe that this spacing option cannot be accessed somehow. If the only option is indeed to use Labeled, I need it in a way that it does not change the original plot whatsoever. No change of ImageSize, No change of ImageMargins, No added spacing etc. I was not able to modify Lableled to do this.

I also dont want to fiddle around to much by placing the text manually as an Inset, or Epiloge etc.

$\endgroup$
4
  • 3
    $\begingroup$ Relevant browsing: 16802. $\endgroup$
    – Syed
    Commented Jun 25, 2023 at 3:36
  • $\begingroup$ Thank you for your input! The proposed solutions work either with Labeled or by fiddeling with text in Epilog. To add a litte bit to the problem: Labeled has two distinct problems: 1. it adds extra space around the plot and 2. the alignment of the text is complicated. I could of course fiddle around with Labeled, Epilog, Text, Inset etc. until I get a satisfying result and I did so in the past. But now I want to find an easier solution. Especially since newer users always stumble across this problem and post the same questions. $\endgroup$ Commented Jun 25, 2023 at 14:04
  • 1
    $\begingroup$ You should use the PlotRangeClipping -> False, Epilog->{Text["smth",{x,y}]} where x and y are coordinates of the "smth" in the coordinate system of the plot. The negative x and y are sitting outside the frame of plot. $\endgroup$
    – Rom38
    Commented Jun 29, 2023 at 9:30
  • $\begingroup$ Nice idea! Anyhow, it leads to problems if PlotRangeClipping is indeed needed. One could make a new empty plot, put the original plot with PlotRangeClipping as an inset and then add the Text, but this is exactly the fiddling I want to avoid. This question is not to find a working solution, but to find a way to easily change this option. $\endgroup$ Commented Jun 30, 2023 at 10:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.