6
$\begingroup$

I have a plot where the x-axis and y-axis coordinates at the origin are really close and kind of overlapping

Plot[x, {x, 2000, 5000}, 
  PlotRange -> {{2000, 5000}, {2000, 5000}}, LabelStyle -> {28, Black, Bold}]

what I have

I want to fix this by moving the x-axis labels down, like below. Is there an easy way to do this?

what I want

$\endgroup$
10
  • $\begingroup$ I would recommend simply not using overly large fonts. Can you explain why you need such huge fonts? In what context do you plan to use this figure? Website? Publication? Poster? If you let us know, perhaps I can show you a reasonable way to make the figure fit in. $\endgroup$
    – Szabolcs
    May 10 '20 at 14:59
  • $\begingroup$ @HighPerformanceMark It took me a while to see the difference too. Look at the tick labels "2000". They overlap $\endgroup$
    – Szabolcs
    May 10 '20 at 15:00
  • 1
    $\begingroup$ Oh, I see, it's one of those puzzles where you have to find 8 differences between two drawings of the 'same' picture. Hang on while I look for the rest :-) $\endgroup$ May 10 '20 at 15:04
  • $\begingroup$ @Szabolcs It's for a publication, but I also make the font large for posters. I found the only way to have the axes readable is to have a fairly large font. I don't know a nice way to avoid it, but please share if you do know one! $\endgroup$ May 10 '20 at 15:34
  • 1
    $\begingroup$ The workflow I use is mostly described in the documentation of my MaTeX package. If you install the package, it can be accessed at the addess MaTeX/tutorial/PreparingFiguresToSize (or just search the docs for MaTeX and there are link to this tutorial at the end of most reference pages). Sorry, I do not have this text in a format independent of the package. The main idea is to prepare figures to a known size. E.g., you decide you want it 8 cm wide (because you verified that this matches the page format that your target journal uses). $\endgroup$
    – Szabolcs
    May 10 '20 at 16:11
4
$\begingroup$

Add a tick with a sufficiently large length in the negative direction:

off = {0, .3};
ticks = Prepend[Charting`ScaledTicks["Linear"][2000, 5000, {10, 5}], 
  {2000., "", off, Red}];

Plot[x, {x, 2000, 5000}, PlotRange -> {{2000, 5000}, {2000, 5000}}, 
 LabelStyle -> {28, Black, Bold}, Ticks -> {ticks, Automatic}, 
 ImageSize -> Large]

enter image description here

Use off = {0, .03} and change Red to Opacity[0] to get

enter image description here

$\endgroup$
3
$\begingroup$

Here is a relative simple way to do it.

Plot[x, {x, 2000, 5000},
  PlotRange -> {{2000, 5000}, {2000, 5000}},
  LabelStyle -> {20, Black, Bold},
  Ticks -> 
    {{#, Column[{"", #}, Spacings -> 0]} & /@ Range[2000, 5000, 500], Automatic},
  ImageSize -> Large]

plot

Update

The following is added to address concerns raised by the OP in a comment to this answer.

To do what you ask for, you have to explicitly specify the length of the major and minor ticks and give the option ImageSize to Columnn. Like so:

Plot[x, {x, 2000, 5000},
  PlotRange -> {{2000, 5000}, {2000, 5000}},
  LabelStyle -> {20, Black, Bold},
  Ticks ->
    {If[Mod[#, 500] == 0,
       {#, Column[{#}, ItemSize -> {Automatic, 1.5}], {.0075, 0}},
       {#, "", {.005, .0}}] & /@ Range[2000, 5000, 100],
    Automatic},
  ImageSize -> Large]

plot

$\endgroup$
3
  • $\begingroup$ How would I keep the minor ticks as they were? $\endgroup$
    – Kvothe
    Apr 6 at 12:31
  • $\begingroup$ Also is there a way to fine tune the skipped height here? Can I make the first entry (the empty one) of the column smaller? $\endgroup$
    – Kvothe
    Apr 6 at 13:17
  • $\begingroup$ @Kvothe. I have made an update which I beleive addresses the issues you raise in your comments. $\endgroup$
    – m_goldberg
    Apr 7 at 16:13

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.