[R] Drawing a dotted circle.

David L Carlson dcarlson at tamu.edu
Sat Jan 12 21:44:07 CET 2013


You can get a dashed line if you plot to pdf() or svg(), but not any of the
bitmap devices. The ellipse() function in the car package will work, but you
have to set up the plot first:

library(car)
plot(c(-1.1, 1.1), c(-1.1, 1.1), type="n", asp=1)
ellipse(c(0, 0), matrix(c(1,0,0,1), 2), 1, lty=2, co="gray", center.pch="")

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Rui Barradas
> Sent: Saturday, January 12, 2013 1:21 PM
> To: Ben Bolker
> Cc: r-help at stat.math.ethz.ch; vedsharma at gmail.com
> Subject: Re: [R] Drawing a dotted circle.
> 
> Hello,
> 
> In Windows it's
> 
> .Internal(symbols(x, y, type, data, inches, bg, fg, ...))
> 
> And this is what I've found:
> file r-2.15.2\src\main\graphics.c
> function GSymbol
> 
>      /*
>       * Force line type LTY_SOLID
>       * i.e., current par(lty) is ignored when drawing symbols
>       */
>      gc.lty = LTY_SOLID;
> 
> 
> So, the op is out of luck, lty solid is hard-coded in the C source.
> Maybe plotrix::draw.circle, like Jose suggested.
> 
> Rui Barradas
> Em 12-01-2013 18:53, Ben Bolker escreveu:
> >    A wild guess which I can't check right now, but: is there
> something
> > funny/different with the Windows graphics driver that draws the
> result
> > of a dashed line based on many closely spaced points as a solid line?
> > i.e., it draws a dash for the beginning of every segment within the
> > line, even if they are close together, resulting in overlapping
> dashes
> > -> a solid line?  Don't have time to dig into
> >
> > .External.graphics(C_symbols, x, y, type, data,
> >          inches, bg, fg, ...)
> >
> >   right now ...
> >
> >
> > On 13-01-12 01:41 PM, Rui Barradas wrote:
> >> Hello,
> >>
> >> Checks ok on Ubuntu 12.04 but not on Windows 7, where it plots a
> solid
> >> line circle.
> >>
> >> symbols(0, 0, circles = 1, inches = FALSE, fg = 'gray', lty=2)
> >> sessionInfo()
> >> R version 2.15.2 (2012-10-26)
> >> Platform: x86_64-w64-mingw32/x64 (64-bit)
> >>
> >> locale:
> >> [1] LC_COLLATE=Portuguese_Portugal.1252
> LC_CTYPE=Portuguese_Portugal.1252
> >> [3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C
> >> [5] LC_TIME=Portuguese_Portugal.1252
> >>
> >> attached base packages:
> >> [1] stats     graphics  grDevices utils     datasets  methods base
> >>
> >> loaded via a namespace (and not attached):
> >> [1] tools_2.15.2
> >>
> >>
> >> Hope this helps,
> >>
> >> Rui Barradas
> >> Em 12-01-2013 17:02, Ben Bolker escreveu:
> >>> Ved P. Sharma <vedsharma <at> gmail.com> writes:
> >>>
> >>>> I am trying to draw a dotted circle by using symbols command:
> >>>>
> >>>> symbols(0, 0, circles = 1, inches = FALSE, fg = 'gray', lty=2)
> >>>>
> >>>> But it gives me a solid line. I was just wondering whether am I
> making a
> >>>> mistake?
> >>>>
> >>>     Works for me (although it's a dashed line; lty=3 gives a dotted
> >>> line) on Ubuntu 10.04, R-devel.  Results of sessionInfo() please?
> >>>
> >>> ______________________________________________
> >>> 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.
> 
> ______________________________________________
> 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