Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to have NumberLinePlot[] display that axis vertically instead of horizontally?

share|improve this question
2  
Rotate[NumberLinePlot[Prime[Range[10]]], 90 Degree] – Hubble07 Jan 22 at 9:03
up vote 10 down vote accepted

I was thinking along the same lines as Hubble07, but I don't care for the way the tick labels get rotated.

Rotate[NumberLinePlot[x^3 < Sin[13 x], x], π/2]

enter image description here

So you can use this,

verticalNumberLinePlot[pred__] := Rotate[
  NumberLinePlot[
   pred,
   Ticks -> {Function[{min, max},
      N@Join[{#, Rotate[#, -π/2], {.01, 0}} & /@ 
         FindDivisions[{min, max}, 5],
        {#, "", {.005, 0}} & /@ FindDivisions[{min, max}, 25]]]}],
  π/2]

It seems to work just as NumberLinePlot, with any option or input specification. I tried on several of the examples on the reference page and none of them broke the functionality.

{verticalNumberLinePlot[x^3 < Sin[13 x], x],
 verticalNumberLinePlot[Prime[Range[10]]],
 verticalNumberLinePlot[{{Interval[{0, 1}]}, Interval[{0, 2}]}]}

enter image description here

Edit I had originally used AbsoluteOptions to get the tick marks, but I found it to be obscenely slow, doesn't work with all versions of Mathematica, and didn't give the best results. So I switched to using a custom tick function as above. I wish the function could be smaller, but I'm happy with the results.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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