1
$\begingroup$

I am plotting large figures and the ticks on the X axes (horizontal) are colliding since there are many trailing zeros from numbers like "1000000" and then directly after the number "2000000".

As an example, I using this code:

lhs[x_, y_] := x^2+y^2
rhs[y_] := 1000^2

s1=1000;
ticks1 = Table[{Sign[i] Sqrt[Abs[i]], i}, {i, -s1, s1, 150}];

s2 = 1000;
ticks2 = Table[{Sign[i] Sqrt[Abs[i]], i}, {i, -s2, s2, 150}];

a=35;
ContourPlot[lhs[Sign[x] x^2, Sign[y] y^2] == rhs[Sign[y] y^2], 
  {x, -a, a}, {y, -a, a}, FrameTicks -> {{ticks1,None},{ticks2,None}}]

Which generates this image:

enter image description here

As you can see, the bottom ticks are all merged together.

Is there a way to make it look a bit nicer, either by rotating by 90 degrees the ticks on the bottom axes so they go "down" instead of "across" or better yet representing the ticks in scientific notation?

$\endgroup$

1 Answer 1

3
$\begingroup$
ContourPlot[
 lhs[Sign[x] x^2, Sign[y] y^2] == rhs[Sign[y] y^2], {x, -a, a}, {y, -a, a},
 FrameTicks :> {{ticks1, None}, {ticks2 /. {a_, b_} :> {a, Rotate[b, Pi/2]}, None}}]

enter image description here

Further options and demo for ScientificForm (don't forget the N!)

ContourPlot[
 lhs[Sign[x] x^2, Sign[y] y^2] == rhs[Sign[y] y^2], {x, -a, a}, {y, -a, a},
   FrameTicks :> {{ticks1, None}, {ticks2[[;; ;; 2]] /. {a_, b_} :> 
     {a, Rotate[ScientificForm[N @ b], Pi/4]}, None}}]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks for you reply, is there a way to write in scientific notation once rotated? Bacuse when the numbers get large it will look silly having 100000000000000000 for example. $\endgroup$
    – Gr Eg
    Commented Aug 2, 2017 at 18:21
  • $\begingroup$ See updated answer $\endgroup$
    – eldo
    Commented Aug 2, 2017 at 18:29
  • $\begingroup$ @GrEg and eldo, IMHO it looks better with the diagonal labels ending at the tick marks; see (9530) $\endgroup$
    – Mr.Wizard
    Commented Aug 5, 2017 at 20:56

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.