[R] Plots with discontinuity balls

Duncan Murdoch murdoch at stats.uwo.ca
Fri Sep 28 13:02:12 CEST 2007


Paul Smith wrote:
> On 9/28/07, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
>   
>>> Can R plot graphs like the one at
>>>
>>> http://www.mathwords.com/f/f_assets/floor_graph.gif
>>>
>>> with the balls at the discontinuity points?
>>>       
>> You can use segments() to draw the segments and symbols() to draw the
>> balls.  For example,
>>
>> plot(1,1,type='n', xlim=c(1,10), ylim=c(1,10))
>> segments(1:9, 1:9, 2:10, 1:9)
>> symbols(2:10, 1:9, circles=rep(0.1,9), inches=FALSE, bg="white",add=T)
>> symbols(1:9, 1:9, circles=rep(0.1,9), inches=FALSE, bg="black",add=T)
>>
>> This depends on the order of drawing, because the white background of
>> the first circles obscures the ends of the segments.
>>     
>
> Thanks, Jim and Duncan. It would help to have transparent backgrounds
> for the white balls.
>   
Then it's even easier:  just use points(), with pch=1, e.g.

plot(1,1,type='n', xlim=c(1,10), ylim=c(1,10))
segments(1:9, 1:9, 2:10, 1:9)
points(2:10, 1:9, pch=1, cex=2)
points(1:9, 1:9, pch=16, cex=2)


> Paul
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list