[R] possible to plot number line in R?

Greg Snow Greg.Snow at imail.org
Wed Jul 7 19:08:06 CEST 2010


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,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Kroepfl, Julia (julia.kroepfl at uni-graz.at)
> Sent: Friday, July 02, 2010 2:40 AM
> To: 'r-help at r-project.org'
> Subject: [R] possible to plot number line in R?
> 
> Thank you very much for your answers, but I think I did not explain
> thoroughly enough what I needed. I attached a demo of the plot. I need
> the number line between 2 and 3, both values being shown on the line,
> interval values should be printed next to the dashes and lines should
> connect the intervals.
> 
> Is this possible to do in R?
> 
> 
> 
> Best Regards,
> 
> Julia
> 



More information about the R-help mailing list