1
$\begingroup$

I wanna have x-axis to be like -10^2,-10^1,10^1,10^2. I usually use the table below but I don't know how to modify the code to show the negative side of the x-axis as well

 Needs["MaTeX`"]
    SetOptions[MaTeX, 
      "Preamble" -> {"\\usepackage{amsmath,amssymb,braket}"}];
    x-axis = Table[{10^i, 
        MaTeX["10^" <> ToString[i], Magnification -> 1.5]}, {i, 3}];
    Plot[1 + z^2, {z, -100, 100}, 
     FrameTicks -> {{Automatic, Automatic}, {x-axis, Automatic}}, 
     Frame -> True,
     FrameStyle -> Black,
     BaseStyle -> 14]

enter image description here

$\endgroup$
2
  • $\begingroup$ change {i, 3} to {i,-2, 2}? $\endgroup$
    – kglr
    Commented Sep 25, 2019 at 6:35
  • $\begingroup$ @kglr no it is not what I want. It gives you, for example, 1o^-2 not -10^2. $\endgroup$
    – sara sam
    Commented Sep 25, 2019 at 17:46

1 Answer 1

2
$\begingroup$

Try

Needs["MaTeX`"]
SetOptions[MaTeX, "Preamble" -> {"\\usepackage{amsmath,amssymb,braket}"}];

range = DeleteCases[Range[-2, 2], 0];
set[i_] := {Sign[i]*10^Abs@i, 
  MaTeX[ If[i < 0, "-10^", "10^"] <> ToString[Abs@i], Magnification -> 1]}

xaxis = Table[set[i], {i, range}];

Plot[1 + z^2, {z, -100, 100}, 
 FrameTicks -> {{Automatic, Automatic}, {xaxis, Automatic}}, 
 Frame -> True, FrameStyle -> Black, BaseStyle -> 14]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ Thanks a lot, it works $\endgroup$
    – sara sam
    Commented Sep 25, 2019 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.