Search code examples
plotwolfram-mathematica

Axes numbers interfere with each other


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


Solution

  • 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