[R] [FORGED] Re: draw stripes in a circle in R
David Winsemius
dwinsemius at comcast.net
Thu Jun 15 03:51:20 CEST 2017
> On Jun 14, 2017, at 5:52 PM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:
>
> Sigh. I never load packages in .Rprofile to avoid the irreproducibility trap. Might seem drastic to some, but I don't feel much pain because I almost always edit my code in a file rather than on the fly at the console, and re-run it frequently from a fresh R process to check my progress.
Yes, <sigh>. But I am a long-time user of the rms/Hmisc combo, as well as the survival package, so near the top of my .Rprofile is:
require(lattice)
require(sos)
require(rms)
Should I be ashamed of that?
I suppose I should, and I _am_ ashamed of some of the other stuff in there ....<delete>, <delete> ... and I've been meaning to address my manifold deficiencies w.r.t. irreproducibility by moving to RStudio, but I keep putting it off.
--
David.
> --
> Sent from my phone. Please excuse my brevity.
>
> On June 14, 2017 3:27:15 PM PDT, David Winsemius <dwinsemius at comcast.net> wrote:
>>
>>> On Jun 14, 2017, at 1:53 PM, Rolf Turner <r.turner at auckland.ac.nz>
>> wrote:
>>>
>>> On 15/06/17 05:29, David Winsemius wrote:
>>>>> On Jun 14, 2017, at 10:18 AM, David Winsemius
>> <dwinsemius at comcast.net> wrote:
>>>>>
>>>>>
>>>>>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller
>> <jdnewmil at dcn.davis.ca.us> wrote:
>>>>>>
>>>>>> I don't see a question. If your question is whether R supports
>> pattern fills, AFAIK it does not. If that is not your question, ask
>> one.
>>>>>> --
>>>>>> Sent from my phone. Please excuse my brevity.
>>>>>>
>>>>>> On June 14, 2017 7:57:41 AM PDT, jean-philippe
>> <jeanphilippe.fontaine at gssi.infn.it> wrote:
>>>>>>> dear R users,
>>>>>>>
>>>>>>> I would like to fill a circle with yellow stripes instead of a
>> uniform
>>>>>>> yellow color. To draw the circle I used the following command
>> after
>>>>>>> having loaded the (very nice !) plotrix library :
>>>> I finally understood the question and it needs a hack to the
>> draw.circle function in plotrix since the angle and density arguments
>> don't get passed in:
>>>> First get code for draw.circle:
>>>> ------
>>>> draw.circle # then copy to console and edit
>>>> draw.circle2 <- function (x, y, radius, nv = 100, border = NULL,
>> col = NA, lty = 1,
>>>> density=NA, angle=45, lwd = 1 )
>>>> {
>>>> xylim <- par("usr")
>>>> plotdim <- par("pin")
>>>> ymult <- getYmult()
>>>> angle.inc <- 2 * pi/nv
>>>> angles <- seq(0, 2 * pi - angle.inc, by = angle.inc)
>>>> if (length(col) < length(radius))
>>>> col <- rep(col, length.out = length(radius))
>>>> for (circle in 1:length(radius)) {
>>>> xv <- cos(angles) * radius[circle] + x
>>>> yv <- sin(angles) * radius[circle] * ymult + y
>>>> polygon(xv, yv, border = border, col = col, lty = lty,
>> density=density, angle=angle,
>>>> lwd = lwd)
>>>> }
>>>> invisible(list(x = xv, y = yv))
>>>> }
>>>> Now run your call to pdf with draw.circle2 instead of draw.circle.
>>>
>>> This is just idle curiosity, since I'm not really able to contribute
>> anything useful, but I can't resist asking: When I try to run the OP's
>> code I get an error:
>>>
>>>> Error in alpha("red", 0.4) : could not find function "alpha".
>>>
>>> Why does this (apparently) not happen to anyone else? Why does the
>> universe pick on *me*? What is the function "alpha()"? Where is it to
>> be found?
>>
>> I discovered some time ago that I no longer needed to load the ggplot2
>> package. I wasn't entirely happy to make this discovery since I stilll
>> cling to the old lattice style. Eventually I figgured out that it was
>> because one of packages that I load in my .Rprofile-file had changed
>> its imports. The `alpha` function I see is from ggplot2. Resistance is
>> futile. I've now been partially assimilated.
>>
>>
>>>
>>> Searching on "alpha" is of course completely unproductive; there are
>> far too many (totally irrelevant) instances.
>>
>>
>>>
>>> cheers,
>>>
>>> Rolf
>>>
>>> --
>>> Technical Editor ANZJS
>>> Department of Statistics
>>> University of Auckland
>>> Phone: +64-9-373-7599 ext. 88276
>>
>> David Winsemius
>> Alameda, CA, USA
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list