轴数相互干扰

时间:2018-11-13 08:21:34

标签: plot wolfram-mathematica

我在Mathematica中有一个绘图,问题是:绘图的轴数相互干扰。如何消除中间数字,例如“ 5 * 10 ^ 12,5 * 10 ^ 13,...”并保留主要数字“ 1 * 10 ^ 12,1 * 10 ^ 13,...” 。还有其他解决方法吗?

Plot

2 个答案:

答案 0 :(得分:0)

使用一个简单的示例,刻度可以像这样固定。引用来自herehere的代码。

首先,显示标签重叠的情况。

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

删除备用标签。

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

答案 1 :(得分:0)

另一种选择是保留所有刻度线标签并旋转它们:

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

相关问题