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?
Asked
Active
Viewed 842 times
2 Answers
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"}]

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"}]
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"}]

Chris Degnen
- 8,443
- 2
- 23
- 40
-
Exact answer! Thank you very much! – Smtl Nov 21 '18 at 08:31