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

  • 2
    $\begingroup$ Rotate[NumberLinePlot[Prime[Range[10]]], 90 Degree] $\endgroup$ – Hubble07 Jan 22 '16 at 9:03

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[
   Ticks -> {Function[{min, max},
      N@Join[{#, Rotate[#, -π/2], {.01, 0}} & /@ 
         FindDivisions[{min, max}, 5],
        {#, "", {.005, 0}} & /@ FindDivisions[{min, max}, 25]]]}],

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[{{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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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