3

I have a plot in Mathematica, and the problem is: the axes numbers of plot interfere with each other. How can I eliminate the middle numbers, For example, "5*10^12, 5*10^13, ..." and keep the main numbers "1*10^12, 1*10^13, ...". is there any other way to solve the problem?

Plot

Smtl
  • 49
  • 6

2 Answers2

2

Another option is to keep all the tick labels and rotate them:

xticks = Charting`ScaledTicks[{Log, Exp}][Log[min], Log[max]];
xticks[[All, 1]] = Exp@xticks[[All, 1]];
xticks[[All, 2]] = Rotate[#, Pi/2] & /@ xticks[[All, 2]];

LogLogPlot[f[x], {x, min, max}, Frame -> True, 
 FrameTicks -> {Automatic, {xticks, Automatic}}, BaseStyle -> 18, 
 FrameLabel -> {"X", "Y"}]

enter image description here

Rohit Namjoshi
  • 669
  • 5
  • 17
0

Using a simple example, the ticks can be fixed like so. Referencing code from here and here.

First, the case showing overlapping labels.

f[x_] := x^2 + x^3

{min, max} = {10^-12, 10^-10};

LogLogPlot[f[x], {x, min, max}, Frame -> True,
 BaseStyle -> 18, FrameLabel -> {"X", "Y"}]

enter image description here

Removing alternate labels.

xticks = Charting`ScaledTicks[{Log, Exp}][Log[min], Log[max]];
xticks[[All, 1]] = Exp@xticks[[All, 1]];
xticks[[All, 2]] = ReplacePart[xticks[[All, 2]],
   Thread[Select[Range@Length@xticks, EvenQ] -> Spacer[{0, 0}]]];

LogLogPlot[f[x], {x, min, max}, Frame -> True,
 FrameTicks -> {Automatic, {xticks, Automatic}},
 BaseStyle -> 18, FrameLabel -> {"X", "Y"}]

enter image description here

Chris Degnen
  • 8,443
  • 2
  • 23
  • 40