Skip to content
Prev 226659 / 398500 Next

possible to plot number line in R?

Here is some code to get you started:


plot.new()
plot.window( c(0,10), c(-1, 1) )

axis(1, at=0:10, pos=0)

lines( c(2,2,5,5), c( -0.25, -0.5, -0.5, -0.25 ) )
text( 3, -0.6, 'Interval 1' )  # the plotrix package has a function for text in a box

lines( c(3,3,6,6), c( 0.1, 0.3, 0.3, 0.1) )
text( 4.5, 0.4, 'Interval 2' )

lines( c(4,4,7,7), c( -0.4, -0.6, -0.6, -0.4 ) )
text( 5.5, -0.7, 'Interval 3' )


pieces could be placed in functions to automate the parts that you want.


hope this helps,