0

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.

mathematica_guy
  • 194
  • 1
  • 9
  • 3
    Relevant browsing: 16802. – Syed Jun 25 '23 at 03:36
  • 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.

    – mathematica_guy Jun 25 '23 at 14:04
  • 1
    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. – Rom38 Jun 29 '23 at 09:30
  • 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. – mathematica_guy Jun 30 '23 at 10:30

0 Answers0