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 : library(plotrix) pdf("MWE.pdf",width=8, height=8) plot(seq(-12.5,-8.7,length.out=100),seq(-11.3,-8.3,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) par(new=T) plot(seq(-12.5,-8.7,length.out=100),seq(-11.7,-8.7,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) par(new=T) polygon(c(seq(-12.5,-8.7,length.out=100), rev(seq(-12.5,-8.7,length.out=100))), c(seq(-11.3,-8.3,length.out=100), rev(seq(-11.7,-8.7,length.out=100))), col = alpha("red",0.4), border = NA) par(new=T) draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=1) dev.off() It looks a bit ugly since they are not real data, but it is the simplest MWE example that I found. Thanks, best Jean-Philippe -- Jean-Philippe Fontaine PhD Student in Astroparticle Physics, Gran Sasso Science Institute (GSSI), Viale Francesco Crispi 7, 67100 L'Aquila, Italy Mobile: +393487128593, +33615653774 ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
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 <[hidden email]> 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 : > >library(plotrix) >pdf("MWE.pdf",width=8, height=8) >plot(seq(-12.5,-8.7,length.out=100),seq(-11.3,-8.3,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >par(new=T) >plot(seq(-12.5,-8.7,length.out=100),seq(-11.7,-8.7,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >par(new=T) >polygon(c(seq(-12.5,-8.7,length.out=100), >rev(seq(-12.5,-8.7,length.out=100))), c(seq(-11.3,-8.3,length.out=100), > >rev(seq(-11.7,-8.7,length.out=100))), > col = alpha("red",0.4), border = NA) >par(new=T) >draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=1) >dev.off() > >It looks a bit ugly since they are not real data, but it is the >simplest >MWE example that I found. > > >Thanks, best > > >Jean-Philippe ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
In reply to this post by jean-philippe fontaine
Sorry for that. Yes my question was whether or not and how is it possible to fill a circle of yellow stripes in R? Is it something that I have to precise in the color argument? Thanks, best Envoyé depuis mon appareil Samsung -------- Message d'origine -------- De : Jeff Newmiller <[hidden email]> Date : 14/06/2017 18:46 (GMT+01:00) À : [hidden email], jean-philippe <[hidden email]>, [hidden email] Objet : Re: [R] draw stripes in a circle in R 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 <[hidden email]> 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 : > >library(plotrix) >pdf("MWE.pdf",width=8, height=8) >plot(seq(-12.5,-8.7,length.out=100),seq(-11.3,-8.3,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >par(new=T) >plot(seq(-12.5,-8.7,length.out=100),seq(-11.7,-8.7,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >par(new=T) >polygon(c(seq(-12.5,-8.7,length.out=100), >rev(seq(-12.5,-8.7,length.out=100))), c(seq(-11.3,-8.3,length.out=100), > >rev(seq(-11.7,-8.7,length.out=100))), > col = alpha("red",0.4), border = NA) >par(new=T) >draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=1) >dev.off() > >It looks a bit ugly since they are not real data, but it is the >simplest >MWE example that I found. > > >Thanks, best > > >Jean-Philippe [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
In reply to this post by Jeff Newmiller
> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller <[hidden email]> 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 <[hidden email]> 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 : >> >> library(plotrix) >> pdf("MWE.pdf",width=8, height=8) >> plot(seq(-12.5,-8.7,length.out=100),seq(-11.3,-8.3,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >> par(new=T) >> plot(seq(-12.5,-8.7,length.out=100),seq(-11.7,-8.7,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >> par(new=T) >> polygon(c(seq(-12.5,-8.7,length.out=100), >> rev(seq(-12.5,-8.7,length.out=100))), c(seq(-11.3,-8.3,length.out=100), >> >> rev(seq(-11.7,-8.7,length.out=100))), >> col = alpha("red",0.4), border = NA) >> par(new=T) >> draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=1) >> dev.off() >> Agree that the coding question remains unclear, so not using the offered example but responding to the natural language query. The `polygon` function has 'density' and 'angle' argument that with 'col' and 'lwd' can make slanted fill lines. This is a modification of hte first example on `?polygon`? x <- c(1:9, 8:1) y <- c(1, 2*(5:3), 2, -1, 17, 9, 8, 2:9) op <- par(mfcol = c(3, 1)) for(xpd in c(FALSE, TRUE, NA)) { plot(1:10, main = paste("xpd =", xpd)) box("figure", col = "pink", lwd = 3) polygon(x, y, xpd = xpd, col = "orange", density=3, angle=45, lwd = 5, border = "red") } The polygon function is _not_ in pkg::plotrix. >> It looks a bit ugly since they are not real data, but it is the >> simplest >> MWE example that I found. >> >> >> Thanks, best >> >> >> Jean-Philippe > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > 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. David Winsemius Alameda, CA, USA ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
> On Jun 14, 2017, at 10:18 AM, David Winsemius <[hidden email]> wrote: > > >> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller <[hidden email]> 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 <[hidden email]> 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 Best; David. >>> >>> library(plotrix) >>> pdf("MWE.pdf",width=8, height=8) >>> plot(seq(-12.5,-8.7,length.out=100),seq(-11.3,-8.3,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >>> par(new=T) >>> plot(seq(-12.5,-8.7,length.out=100),seq(-11.7,-8.7,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >>> par(new=T) >>> polygon(c(seq(-12.5,-8.7,length.out=100), >>> rev(seq(-12.5,-8.7,length.out=100))), c(seq(-11.3,-8.3,length.out=100), >>> >>> rev(seq(-11.7,-8.7,length.out=100))), >>> col = alpha("red",0.4), border = NA) >>> par(new=T) >>> draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=1) >>> dev.off() >>> > > Agree that the coding question remains unclear, so not using the offered example but responding to the natural language query. The `polygon` function has 'density' and 'angle' argument that with 'col' and 'lwd' can make slanted fill lines. This is a modification of hte first example on `?polygon`? > > x <- c(1:9, 8:1) > y <- c(1, 2*(5:3), 2, -1, 17, 9, 8, 2:9) > op <- par(mfcol = c(3, 1)) > for(xpd in c(FALSE, TRUE, NA)) { > plot(1:10, main = paste("xpd =", xpd)) > box("figure", col = "pink", lwd = 3) > polygon(x, y, xpd = xpd, col = "orange", density=3, angle=45, lwd = 5, border = "red") > } > > The polygon function is _not_ in pkg::plotrix. > > > >>> It looks a bit ugly since they are not real data, but it is the >>> simplest >>> MWE example that I found. >>> >>> >>> Thanks, best >>> >>> >>> Jean-Philippe >> >> ______________________________________________ >> [hidden email] mailing list -- To UNSUBSCRIBE and more, see >> 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. > > David Winsemius > Alameda, CA, USA > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > 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. David Winsemius Alameda, CA, USA ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
On 15/06/17 05:29, David Winsemius wrote:
> >> On Jun 14, 2017, at 10:18 AM, David Winsemius <[hidden email]> wrote: >> >> >>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller <[hidden email]> 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 <[hidden email]> 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? 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 ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
In reply to this post by jean-philippe fontaine
Envoyé depuis mon appareil Samsung -------- Message d'origine -------- De : Rolf Turner <[hidden email]> Date : 14/06/2017 22:53 (GMT+01:00) À : David Winsemius <[hidden email]> Cc : [hidden email] Objet : Re: [R] [FORGED] Re: draw stripes in a circle in R On 15/06/17 05:29, David Winsemius wrote: > >> On Jun 14, 2017, at 10:18 AM, David Winsemius <[hidden email]> wrote: >> >> >>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller <[hidden email]> 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 <[hidden email]> 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". Sorry for the lack of precision, alpha is just to add some transparency to the color. This alpha parameter ranges from 0 fully transparent to 1, full color.I don't remember having loaded any package to use this function, I think it is there in base R. 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? 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 ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
Hi Jean-Phillipe,
Thanks for the plug on plotrix. Because of that I will suggest a gross hack that will do almost what you want: # your code down to draw.circle segments(c(-12.7,-12.7),c(-11.2,-10.6),c(-12,-12), c(-10.75,-10.15),col="white",lwd=28) draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL, col=NA,lty=1,lwd=1) box() dev.off() Your problem is that plotrix is written in base graphics, which is simple to understand, but does not support layered graphics. Thus I have to do the striping over the yellow circle and avoid overwriting the big red stripe. You should do this using the grid graphic system, but that would take too large a chunk of my morning to write an example for you. To Rolf - It happened to me as well, but because I saw Venus smiling at me in the sky this morning I was granted the knowledge that it was a function that had not been properly introduced to us and simply replaced it with "red". Such are the benefits of evidence-based astrology. Jim On Thu, Jun 15, 2017 at 8:04 AM, jeanphilippe.fontaine <[hidden email]> wrote: > > > > > > > Envoyé depuis mon appareil Samsung > > -------- Message d'origine -------- > De : Rolf Turner <[hidden email]> > Date : 14/06/2017 22:53 (GMT+01:00) > À : David Winsemius <[hidden email]> > Cc : [hidden email] > Objet : Re: [R] [FORGED] Re: draw stripes in a circle in R > > On 15/06/17 05:29, David Winsemius wrote: >> >>> On Jun 14, 2017, at 10:18 AM, David Winsemius <[hidden email]> wrote: >>> >>> >>>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller <[hidden email]> 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 <[hidden email]> 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". > > Sorry for the lack of precision, alpha is just to add some transparency to the color. This alpha parameter ranges from 0 fully transparent to 1, full color.I don't remember having loaded any package to use this function, I think it is there in base R. > 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? > > 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 > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > 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. > > [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > 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. ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
In reply to this post by Rolf Turner
> On Jun 14, 2017, at 1:53 PM, Rolf Turner <[hidden email]> wrote: > > On 15/06/17 05:29, David Winsemius wrote: >>> On Jun 14, 2017, at 10:18 AM, David Winsemius <[hidden email]> wrote: >>> >>> >>>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller <[hidden email]> 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 <[hidden email]> 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 ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
In reply to this post by Rolf Turner
Package 'scales' has the alpha function... associated with ggplot2. A bit out of place here if that is the origin. Yes, we are squarely in non-reproducible example territory, also known as the Twilight Zone.
-- Sent from my phone. Please excuse my brevity. On June 14, 2017 1:53:21 PM PDT, Rolf Turner <[hidden email]> wrote: >On 15/06/17 05:29, David Winsemius wrote: >> >>> On Jun 14, 2017, at 10:18 AM, David Winsemius ><[hidden email]> wrote: >>> >>> >>>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller ><[hidden email]> 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 ><[hidden email]> 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? > >Searching on "alpha" is of course completely unproductive; there are >far >too many (totally irrelevant) instances. > >cheers, > >Rolf ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
In reply to this post by David Winsemius
On 15/06/17 10:27, David Winsemius wrote:
> >> On Jun 14, 2017, at 1:53 PM, Rolf Turner <[hidden email]> wrote: <SNIP> >> 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. N'ya-hah! The light dawns! Thank you. cheers, Rolf -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
In reply to this post by David Winsemius
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.
-- Sent from my phone. Please excuse my brevity. On June 14, 2017 3:27:15 PM PDT, David Winsemius <[hidden email]> wrote: > >> On Jun 14, 2017, at 1:53 PM, Rolf Turner <[hidden email]> >wrote: >> >> On 15/06/17 05:29, David Winsemius wrote: >>>> On Jun 14, 2017, at 10:18 AM, David Winsemius ><[hidden email]> wrote: >>>> >>>> >>>>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller ><[hidden email]> 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 ><[hidden email]> 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 ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
> On Jun 14, 2017, at 5:52 PM, Jeff Newmiller <[hidden email]> 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 <[hidden email]> wrote: >> >>> On Jun 14, 2017, at 1:53 PM, Rolf Turner <[hidden email]> >> wrote: >>> >>> On 15/06/17 05:29, David Winsemius wrote: >>>>> On Jun 14, 2017, at 10:18 AM, David Winsemius >> <[hidden email]> wrote: >>>>> >>>>> >>>>>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller >> <[hidden email]> 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 >> <[hidden email]> 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 ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
On 15/06/17 13:51, David Winsemius wrote:
> >> On Jun 14, 2017, at 5:52 PM, Jeff Newmiller <[hidden email]> 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. This is getting *way* off topic ... but why does using RStudio help with the irreproducibility problem? I thought that RStudio just made it easier to point-and-click. For those who like doing that sort of thing. (I tend to believe the dictum that a GUI makes it easy to do easy things and impossible to do hard things.) cheers, Rolf -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
In reply to this post by David Winsemius
hi david
Thank you very much for the hack of draw.circle that you proposed me. I don't understand some part of the code, why do you pass radius as a vector in the function (if I understand well the purpose of the for loop) ? Also what is ymult? If I set the radius to the value 0.85 as I wanted (so as a scalar), I don't see any difference in the result when I call this function draw.circle2, the stripes are not drawn inside the circle. I don't know if it is normal. Thanks, best Jean-Philippe On 14/06/2017 19:29, David Winsemius wrote: >> On Jun 14, 2017, at 10:18 AM, David Winsemius <[hidden email]> wrote: >> >> >>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller <[hidden email]> 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 <[hidden email]> 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 > > Best; > David. >>>> library(plotrix) >>>> pdf("MWE.pdf",width=8, height=8) >>>> plot(seq(-12.5,-8.7,length.out=100),seq(-11.3,-8.3,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >>>> par(new=T) >>>> plot(seq(-12.5,-8.7,length.out=100),seq(-11.7,-8.7,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >>>> par(new=T) >>>> polygon(c(seq(-12.5,-8.7,length.out=100), >>>> rev(seq(-12.5,-8.7,length.out=100))), c(seq(-11.3,-8.3,length.out=100), >>>> >>>> rev(seq(-11.7,-8.7,length.out=100))), >>>> col = alpha("red",0.4), border = NA) >>>> par(new=T) >>>> draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=1) >>>> dev.off() >>>> >> Agree that the coding question remains unclear, so not using the offered example but responding to the natural language query. The `polygon` function has 'density' and 'angle' argument that with 'col' and 'lwd' can make slanted fill lines. This is a modification of hte first example on `?polygon`? >> >> x <- c(1:9, 8:1) >> y <- c(1, 2*(5:3), 2, -1, 17, 9, 8, 2:9) >> op <- par(mfcol = c(3, 1)) >> for(xpd in c(FALSE, TRUE, NA)) { >> plot(1:10, main = paste("xpd =", xpd)) >> box("figure", col = "pink", lwd = 3) >> polygon(x, y, xpd = xpd, col = "orange", density=3, angle=45, lwd = 5, border = "red") >> } >> >> The polygon function is _not_ in pkg::plotrix. >> >> >> >>>> It looks a bit ugly since they are not real data, but it is the >>>> simplest >>>> MWE example that I found. >>>> >>>> >>>> Thanks, best >>>> >>>> >>>> Jean-Philippe >>> ______________________________________________ >>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see >>> 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. >> David Winsemius >> Alameda, CA, USA >> >> ______________________________________________ >> [hidden email] mailing list -- To UNSUBSCRIBE and more, see >> 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. > David Winsemius > Alameda, CA, USA > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > 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. -- Jean-Philippe Fontaine PhD Student in Astroparticle Physics, Gran Sasso Science Institute (GSSI), Viale Francesco Crispi 7, 67100 L'Aquila, Italy Mobile: +393487128593, +33615653774 ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. |
> On Jun 15, 2017, at 1:35 AM, jean-philippe <[hidden email]> wrote: > > hi david > > Thank you very much for the hack of draw.circle that you proposed me. > I don't understand some part of the code, why do you pass radius as a vector in the function (if I understand well the purpose of the for loop) ? Also what is ymult? > > If I set the radius to the value 0.85 as I wanted (so as a scalar), I don't see any difference in the result when I call this function draw.circle2, the stripes are not drawn inside the circle. I don't know if it is normal. It certainly wasn't intended. I expected the radius argument to get used repeatedly just as it is in the original function, but remain a scalar. Did you just copy-paste my code or do your own alterations? And did you add the arguments to the new call? When I use: Your set-up surrounds this: draw.circle2(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=5, density=2, angle=45) I get the attached pdf: I don't think you are interpreting the code in the same manner as I do. When hacking someone else code it's probably a good idea to give all the arguments names. That way you uncover errors in the argument passing better because name collision get flagged and the error messages become more meaningful. Feel free to post annotations using the octothorpe method in between lines to explain how you understand the code. -- David. > > > Thanks, best > > > Jean-Philippe > > On 14/06/2017 19:29, David Winsemius wrote: >>> On Jun 14, 2017, at 10:18 AM, David Winsemius <[hidden email]> wrote: >>> >>> >>>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller <[hidden email]> 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 <[hidden email]> 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 >> >> Best; >> David. >>>>> library(plotrix) >>>>> pdf("MWE.pdf",width=8, height=8) >>>>> plot(seq(-12.5,-8.7,length.out=100),seq(-11.3,-8.3,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >>>>> par(new=T) >>>>> plot(seq(-12.5,-8.7,length.out=100),seq(-11.7,-8.7,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >>>>> par(new=T) >>>>> polygon(c(seq(-12.5,-8.7,length.out=100), >>>>> rev(seq(-12.5,-8.7,length.out=100))), c(seq(-11.3,-8.3,length.out=100), >>>>> >>>>> rev(seq(-11.7,-8.7,length.out=100))), >>>>> col = alpha("red",0.4), border = NA) >>>>> par(new=T) >>>>> draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=1) >>>>> dev.off() >>>>> >>> Agree that the coding question remains unclear, so not using the offered example but responding to the natural language query. The `polygon` function has 'density' and 'angle' argument that with 'col' and 'lwd' can make slanted fill lines. This is a modification of hte first example on `?polygon`? >>> >>> x <- c(1:9, 8:1) >>> y <- c(1, 2*(5:3), 2, -1, 17, 9, 8, 2:9) >>> op <- par(mfcol = c(3, 1)) >>> for(xpd in c(FALSE, TRUE, NA)) { >>> plot(1:10, main = paste("xpd =", xpd)) >>> box("figure", col = "pink", lwd = 3) >>> polygon(x, y, xpd = xpd, col = "orange", density=3, angle=45, lwd = 5, border = "red") >>> } >>> >>> The polygon function is _not_ in pkg::plotrix. >>> >>> >>> >>>>> It looks a bit ugly since they are not real data, but it is the >>>>> simplest >>>>> MWE example that I found. >>>>> >>>>> >>>>> Thanks, best >>>>> >>>>> >>>>> Jean-Philippe >>>> ______________________________________________ >>>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see >>>> 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. >>> David Winsemius >>> Alameda, CA, USA >>> >>> ______________________________________________ >>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see >>> 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. >> David Winsemius >> Alameda, CA, USA >> >> ______________________________________________ >> [hidden email] mailing list -- To UNSUBSCRIBE and more, see >> 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. > > -- > Jean-Philippe Fontaine > PhD Student in Astroparticle Physics, > Gran Sasso Science Institute (GSSI), > Viale Francesco Crispi 7, > 67100 L'Aquila, Italy > Mobile: +393487128593, +33615653774 > Alameda, CA, USA ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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. MWE.pdf (13K) Download Attachment |
Free forum by Nabble | Edit this page |