miguel.angel.rodriguez.muinos en sergas.es
2012-Dec-14 11:10 UTC
[R-es] Feliz Navidad (R code)
f.x = c(0.193,0.703,0.703,0.295,0.295,0.703,0.703,0.295,0.295,0.193,0.193) f.y = c(0.935,0.935,0.835,0.835,0.575,0.575,0.475,0.475,0.063,0.063,0.935) e.x = c(0.222, 0.787, 0.787, 0.324, 0.324, 0.757, 0.757, 0.324, 0.324,0.804, 0.804, 0.222) e.y = c(0.935, 0.935, 0.834, 0.834, 0.564, 0.564, 0.464, 0.464, 0.163,0.163, 0.063, 0.063) l.x = c(0.222,0.324,0.324,0.804,0.804,0.222) l.y = c(0.935,0.935,0.163,0.163,0.063,0.063) a1.x = c(0.433, 0.546, 0.865, 0.746, 0.656, 0.328, 0.242, 0.136) a1.y = c(0.935, 0.935, 0.063, 0.063, 0.326, 0.326, 0.063, 0.063) a2.x = c(0.488, 0.629, 0.355) a2.y = c(0.841, 0.418, 0.418) n.x = c(0.189, 0.295, 0.707, 0.707, 0.804, 0.804, 0.701, 0.287, 0.287, 0.189) n.y = c(0.935, 0.935, 0.248, 0.935, 0.935, 0.063, 0.063, 0.747, 0.063, 0.063) d.x = c(0.218,0.56,0.56,0.56,0.56,0.32,0.218,0.32,0.32) d.y = c(0.935,0.933,0.832,0.518,0.418,0.063,0.063,0.518,0.834) d.cir.th = seq(pi/2, -pi/2, length.out = 50) d1.cir.x = 0.32 + 0.515 * cos(d.cir.th) d1.cir.y = 0.499 + 0.436 * sin(d.cir.th) d2.cir.x = 0.32 + 0.4147 * cos(d.cir.th) d2.cir.y = 0.499 + 0.3 * sin(d.cir.th) d1.x = c(0.218, d1.cir.x, 0.32, 0.218) d1.y = c(0.935, d1.cir.y, 0.063, 0.063) d2.x = c(0.32, d2.cir.x, 0.32) d2.y = c(0.799, d2.cir.y,0.199) n.x = c(0.189, 0.295, 0.707, 0.707, 0.804, 0.804, 0.701, 0.287, 0.287, 0.189) n.y = c(0.935, 0.935, 0.248, 0.935, 0.935, 0.063, 0.063, 0.747, 0.063, 0.063) i.x = c(0.189, 0.295, 0.295, 0.189, 0.189) i.y = c(0.935, 0.935, 0.063, 0.063, 0.935) e.x = c(0.222, 0.787, 0.787, 0.324, 0.324, 0.757, 0.757, 0.324, 0.324,0.804, 0.804, 0.222) e.y = c(0.935, 0.935, 0.834, 0.834, 0.564, 0.564, 0.464, 0.464, 0.163,0.163, 0.063, 0.063) z.x = c(0.222,0.787,0.787,0.322,0.804,0.804,0.222,0.222,0.687,0.222) z.y = c(0.935,0.935,0.834,0.163,0.163,0.063,0.063,0.163,0.834,0.834) v.x = c(0.136, 0.259, 0.496, 0.734, 0.853, 0.543, 0.441) v.y = c(0.935, 0.935, 0.163, 0.935, 0.935, 0.063, 0.063) draw.ch = function(x1, y1, x2 = NULL, y2 = NULL, center.x, color, alpha, xscale) { rgb.col = col2rgb(color)/255 x1 = x1 * xscale + center.x - 0.5 * xscale x2 = x2 * xscale + center.x - 0.5 * xscale polygon(x1, y1, col = rgb(rgb.col[1], rgb.col[2], rgb.col[3], alpha = alpha), border = NA) # polygon(x2, y2, col = "black", border = NA) polygon(x2, y2, col = "white", border = NA) } x1 = list(f.x, e.x, l.x, i.x, z.x, n.x, a1.x,v.x,i.x,d1.x,a1.x,d1.x) y1 = list(f.y,e.y,l.y,i.y,z.y,n.y,a1.y,v.y,i.y,d1.y,a1.y,d1.y) x2 = list(NULL,NULL,NULL,NULL,NULL,NULL,a2.x,NULL,NULL,d2.x,a2.x,d2.x) y2 = list(NULL,NULL,NULL,NULL,NULL,NULL,a2.y,NULL,NULL,d2.y,a2.y,d2.y) th = seq(pi/6, 2 * pi, length.out = 12) cols = rainbow(200) for (j in 1:999) { th = th - pi/120 center.x = 3 + 5 * cos(th) cols = c(cols[-1], cols[1]) alpha = 0.1 + (50 * (1 - sin(th)))/100 alpha = ifelse(alpha > 1, 1, alpha) xscale = -sin(th) * 1.2 plot(1, xlim = c(-2, 8), ylim = c(-2.5, 3.5), type = "n") plot.order = (1:12)[order(xscale > 0)] for (k in 1:12) { i = plot.order[k] draw.ch(x1[[i]], y1[[i]], x2[[i]], y2[[i]], center.x[i], color = cols[k + 60 * ( i >= 6 & i <= 8 ) + 120 * (i > 8)], alpha[i], xscale[i]) } } ## Un Saludo, ## ________________________________________________________ ## Miguel Ángel Rodríguez Muíños ## @mianromu ## Dirección Xeral de Innovación e Xestión da Saúde Pública ## Consellería de Sanidade ## Xunta de Galicia ## ## http://dxsp.sergas.es Nota: A información contida nesta mensaxe e os seus posibles documentos adxuntos é privada e confidencial e está dirixida únicamente ó seu destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, por favor elimínea. A distribución ou copia desta mensaxe non está autorizada. Nota: La información contenida en este mensaje y sus posibles documentos adjuntos es privada y confidencial y está dirigida únicamente a su destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, por favor elimínelo. La distribución o copia de este mensaje no está autorizada. See more languages: http://www.sergas.es/aviso_confidencialidad.htm
Muchas gracias Miguel Angel. Muy original, y muy friki jejeje. Feliz Navidad para ti también! El 14/12/2012 12:10, miguel.angel.rodriguez.muinos en sergas.es escribió:> f.x = c(0.193,0.703,0.703,0.295,0.295,0.703,0.703,0.295,0.295,0.193,0.193) > f.y = c(0.935,0.935,0.835,0.835,0.575,0.575,0.475,0.475,0.063,0.063,0.935) > e.x = c(0.222, 0.787, 0.787, 0.324, 0.324, 0.757, 0.757, 0.324, 0.324,0.804, 0.804, 0.222) > e.y = c(0.935, 0.935, 0.834, 0.834, 0.564, 0.564, 0.464, 0.464, 0.163,0.163, 0.063, 0.063) > l.x = c(0.222,0.324,0.324,0.804,0.804,0.222) > l.y = c(0.935,0.935,0.163,0.163,0.063,0.063) > a1.x = c(0.433, 0.546, 0.865, 0.746, 0.656, 0.328, 0.242, 0.136) > a1.y = c(0.935, 0.935, 0.063, 0.063, 0.326, 0.326, 0.063, 0.063) > a2.x = c(0.488, 0.629, 0.355) > a2.y = c(0.841, 0.418, 0.418) > n.x = c(0.189, 0.295, 0.707, 0.707, 0.804, 0.804, 0.701, 0.287, 0.287, 0.189) > n.y = c(0.935, 0.935, 0.248, 0.935, 0.935, 0.063, 0.063, 0.747, 0.063, 0.063) > d.x = c(0.218,0.56,0.56,0.56,0.56,0.32,0.218,0.32,0.32) > d.y = c(0.935,0.933,0.832,0.518,0.418,0.063,0.063,0.518,0.834) > d.cir.th = seq(pi/2, -pi/2, length.out = 50) > d1.cir.x = 0.32 + 0.515 * cos(d.cir.th) > d1.cir.y = 0.499 + 0.436 * sin(d.cir.th) > d2.cir.x = 0.32 + 0.4147 * cos(d.cir.th) > d2.cir.y = 0.499 + 0.3 * sin(d.cir.th) > d1.x = c(0.218, d1.cir.x, 0.32, 0.218) > d1.y = c(0.935, d1.cir.y, 0.063, 0.063) > d2.x = c(0.32, d2.cir.x, 0.32) > d2.y = c(0.799, d2.cir.y,0.199) > n.x = c(0.189, 0.295, 0.707, 0.707, 0.804, 0.804, 0.701, 0.287, 0.287, 0.189) > n.y = c(0.935, 0.935, 0.248, 0.935, 0.935, 0.063, 0.063, 0.747, 0.063, 0.063) > i.x = c(0.189, 0.295, 0.295, 0.189, 0.189) > i.y = c(0.935, 0.935, 0.063, 0.063, 0.935) > e.x = c(0.222, 0.787, 0.787, 0.324, 0.324, 0.757, 0.757, 0.324, 0.324,0.804, 0.804, 0.222) > e.y = c(0.935, 0.935, 0.834, 0.834, 0.564, 0.564, 0.464, 0.464, 0.163,0.163, 0.063, 0.063) > z.x = c(0.222,0.787,0.787,0.322,0.804,0.804,0.222,0.222,0.687,0.222) > z.y = c(0.935,0.935,0.834,0.163,0.163,0.063,0.063,0.163,0.834,0.834) > v.x = c(0.136, 0.259, 0.496, 0.734, 0.853, 0.543, 0.441) > v.y = c(0.935, 0.935, 0.163, 0.935, 0.935, 0.063, 0.063) > draw.ch = function(x1, y1, x2 = NULL, y2 = NULL, center.x, > color, alpha, xscale) { > rgb.col = col2rgb(color)/255 > x1 = x1 * xscale + center.x - 0.5 * xscale > x2 = x2 * xscale + center.x - 0.5 * xscale > polygon(x1, y1, col = rgb(rgb.col[1], rgb.col[2], rgb.col[3], > alpha = alpha), border = NA) > # polygon(x2, y2, col = "black", border = NA) > polygon(x2, y2, col = "white", border = NA) > } > x1 = list(f.x, e.x, l.x, i.x, z.x, n.x, a1.x,v.x,i.x,d1.x,a1.x,d1.x) > y1 = list(f.y,e.y,l.y,i.y,z.y,n.y,a1.y,v.y,i.y,d1.y,a1.y,d1.y) > x2 = list(NULL,NULL,NULL,NULL,NULL,NULL,a2.x,NULL,NULL,d2.x,a2.x,d2.x) > y2 = list(NULL,NULL,NULL,NULL,NULL,NULL,a2.y,NULL,NULL,d2.y,a2.y,d2.y) > th = seq(pi/6, 2 * pi, length.out = 12) > cols = rainbow(200) > for (j in 1:999) { > th = th - pi/120 > center.x = 3 + 5 * cos(th) > cols = c(cols[-1], cols[1]) > alpha = 0.1 + (50 * (1 - sin(th)))/100 > alpha = ifelse(alpha > 1, 1, alpha) > xscale = -sin(th) * 1.2 > plot(1, xlim = c(-2, 8), ylim = c(-2.5, 3.5), type = "n") > plot.order = (1:12)[order(xscale > 0)] > for (k in 1:12) { > i = plot.order[k] > draw.ch(x1[[i]], y1[[i]], x2[[i]], y2[[i]], center.x[i], > color = cols[k + 60 * ( i >= 6 & i <= 8 ) + 120 * > (i > 8)], alpha[i], xscale[i]) > } > } > > > ## Un Saludo, > ## ________________________________________________________ > ## Miguel Ángel Rodríguez Muíños > ## @mianromu > ## Dirección Xeral de Innovación e Xestión da Saúde Pública > ## Consellería de Sanidade > ## Xunta de Galicia > ## > ## http://dxsp.sergas.es > > > > > > > > > > > > > > > > > > Nota: A información contida nesta mensaxe e os seus posibles documentos adxuntos é privada e confidencial e está dirixida únicamente ó seu destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, por favor elimínea. A distribución ou copia desta mensaxe non está autorizada. > > Nota: La información contenida en este mensaje y sus posibles documentos adjuntos es privada y confidencial y está dirigida únicamente a su destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, por favor elimínelo. La distribución o copia de este mensaje no está autorizada. > > See more languages: http://www.sergas.es/aviso_confidencialidad.htm > > _______________________________________________ > R-help-es mailing list > R-help-es en r-project.org > https://stat.ethz.ch/mailman/listinfo/r-help-es > > >
Gracias!! Sugiero un par de mejoras. Una estética a la hora de dibujar el gráfico y otra para que incluso en RStudio funcione sin problemas (creando una ventana nueva)... Lo destaco en el código. #################################### *win.graph(width=800, height=600)* for (j in 1:999) { for (j in 1:999) { th = th - pi/120 center.x = 3 + 5 * cos(th) cols = c(cols[-1], cols[1]) alpha = 0.1 + (50 * (1 - sin(th)))/100 alpha = ifelse(alpha > 1, 1, alpha) xscale = -sin(th) * 1.2 plot(1, xlim = c(-2, 8), ylim = c(-2.5, 3.5), type = "n", *axes=F, ylab="", xlab=""*) plot.order = (1:12)[order(xscale > 0)] for (k in 1:12) { i = plot.order[k] draw.ch(x1[[i]], y1[[i]], x2[[i]], y2[[i]], center.x[i], color = cols[k + 60 * ( i >= 6 & i <= 8 ) + 120 * (i > 8)], alpha[i], xscale[i]) } } #################################### Saludos, Carlos Ortega www.qualityexcellence.es 2012/12/14 <miguel.angel.rodriguez.muinos@sergas.es>> f.x = c(0.193,0.703,0.703,0.295,0.295,0.703,0.703,0.295,0.295,0.193,0.193) > f.y = c(0.935,0.935,0.835,0.835,0.575,0.575,0.475,0.475,0.063,0.063,0.935) > e.x = c(0.222, 0.787, 0.787, 0.324, 0.324, 0.757, 0.757, 0.324, > 0.324,0.804, 0.804, 0.222) > e.y = c(0.935, 0.935, 0.834, 0.834, 0.564, 0.564, 0.464, 0.464, > 0.163,0.163, 0.063, 0.063) > l.x = c(0.222,0.324,0.324,0.804,0.804,0.222) > l.y = c(0.935,0.935,0.163,0.163,0.063,0.063) > a1.x = c(0.433, 0.546, 0.865, 0.746, 0.656, 0.328, 0.242, 0.136) > a1.y = c(0.935, 0.935, 0.063, 0.063, 0.326, 0.326, 0.063, 0.063) > a2.x = c(0.488, 0.629, 0.355) > a2.y = c(0.841, 0.418, 0.418) > n.x = c(0.189, 0.295, 0.707, 0.707, 0.804, 0.804, 0.701, 0.287, 0.287, > 0.189) > n.y = c(0.935, 0.935, 0.248, 0.935, 0.935, 0.063, 0.063, 0.747, 0.063, > 0.063) > d.x = c(0.218,0.56,0.56,0.56,0.56,0.32,0.218,0.32,0.32) > d.y = c(0.935,0.933,0.832,0.518,0.418,0.063,0.063,0.518,0.834) > d.cir.th = seq(pi/2, -pi/2, length.out = 50) > d1.cir.x = 0.32 + 0.515 * cos(d.cir.th) > d1.cir.y = 0.499 + 0.436 * sin(d.cir.th) > d2.cir.x = 0.32 + 0.4147 * cos(d.cir.th) > d2.cir.y = 0.499 + 0.3 * sin(d.cir.th) > d1.x = c(0.218, d1.cir.x, 0.32, 0.218) > d1.y = c(0.935, d1.cir.y, 0.063, 0.063) > d2.x = c(0.32, d2.cir.x, 0.32) > d2.y = c(0.799, d2.cir.y,0.199) > n.x = c(0.189, 0.295, 0.707, 0.707, 0.804, 0.804, 0.701, 0.287, 0.287, > 0.189) > n.y = c(0.935, 0.935, 0.248, 0.935, 0.935, 0.063, 0.063, 0.747, 0.063, > 0.063) > i.x = c(0.189, 0.295, 0.295, 0.189, 0.189) > i.y = c(0.935, 0.935, 0.063, 0.063, 0.935) > e.x = c(0.222, 0.787, 0.787, 0.324, 0.324, 0.757, 0.757, 0.324, > 0.324,0.804, 0.804, 0.222) > e.y = c(0.935, 0.935, 0.834, 0.834, 0.564, 0.564, 0.464, 0.464, > 0.163,0.163, 0.063, 0.063) > z.x = c(0.222,0.787,0.787,0.322,0.804,0.804,0.222,0.222,0.687,0.222) > z.y = c(0.935,0.935,0.834,0.163,0.163,0.063,0.063,0.163,0.834,0.834) > v.x = c(0.136, 0.259, 0.496, 0.734, 0.853, 0.543, 0.441) > v.y = c(0.935, 0.935, 0.163, 0.935, 0.935, 0.063, 0.063) > draw.ch = function(x1, y1, x2 = NULL, y2 = NULL, center.x, > color, alpha, xscale) { > rgb.col = col2rgb(color)/255 > x1 = x1 * xscale + center.x - 0.5 * xscale > x2 = x2 * xscale + center.x - 0.5 * xscale > polygon(x1, y1, col = rgb(rgb.col[1], rgb.col[2], rgb.col[3], > alpha = alpha), border = NA) > # polygon(x2, y2, col = "black", border = NA) > polygon(x2, y2, col = "white", border = NA) > } > x1 = list(f.x, e.x, l.x, i.x, z.x, n.x, a1.x,v.x,i.x,d1.x,a1.x,d1.x) > y1 = list(f.y,e.y,l.y,i.y,z.y,n.y,a1.y,v.y,i.y,d1.y,a1.y,d1.y) > x2 = list(NULL,NULL,NULL,NULL,NULL,NULL,a2.x,NULL,NULL,d2.x,a2.x,d2.x) > y2 = list(NULL,NULL,NULL,NULL,NULL,NULL,a2.y,NULL,NULL,d2.y,a2.y,d2.y) > th = seq(pi/6, 2 * pi, length.out = 12) > cols = rainbow(200) > for (j in 1:999) { > th = th - pi/120 > center.x = 3 + 5 * cos(th) > cols = c(cols[-1], cols[1]) > alpha = 0.1 + (50 * (1 - sin(th)))/100 > alpha = ifelse(alpha > 1, 1, alpha) > xscale = -sin(th) * 1.2 > plot(1, xlim = c(-2, 8), ylim = c(-2.5, 3.5), type = "n") > plot.order = (1:12)[order(xscale > 0)] > for (k in 1:12) { > i = plot.order[k] > draw.ch(x1[[i]], y1[[i]], x2[[i]], y2[[i]], center.x[i], > color = cols[k + 60 * ( i >= 6 & i <= 8 ) + 120 * > (i > 8)], alpha[i], xscale[i]) > } > } > > > ## Un Saludo, > ## ________________________________________________________ > ## Miguel Ángel Rodríguez Muíños > ## @mianromu > ## Dirección Xeral de Innovación e Xestión da Saúde Pública > ## Consellería de Sanidade > ## Xunta de Galicia > ## > ## http://dxsp.sergas.es > > > > > > > > > > > > > > > > > > Nota: A información contida nesta mensaxe e os seus posibles documentos > adxuntos é privada e confidencial e está dirixida únicamente ó seu > destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, > por favor elimínea. A distribución ou copia desta mensaxe non está > autorizada. > > Nota: La información contenida en este mensaje y sus posibles documentos > adjuntos es privada y confidencial y está dirigida únicamente a su > destinatario/a. Si usted no es el/la destinatario/a original de este > mensaje, por favor elimínelo. La distribución o copia de este mensaje no > está autorizada. > > See more languages: http://www.sergas.es/aviso_confidencialidad.htm > > _______________________________________________ > R-help-es mailing list > R-help-es@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-help-es >-- Saludos, Carlos Ortega www.qualityexcellence.es [[alternative HTML version deleted]]
Uf, disculpad del copy&paste introduje un bucle adicional. Este es el código correcto... ########################################### *win.graph(width=800, height=600)* for (j in 1:999) { th = th - pi/120 center.x = 3 + 5 * cos(th) cols = c(cols[-1], cols[1]) alpha = 0.1 + (50 * (1 - sin(th)))/100 alpha = ifelse(alpha > 1, 1, alpha) xscale = -sin(th) * 1.2 plot(1, xlim = c(-2, 8), ylim = c(-2.5, 3.5), type = "n",* axes=F, ylab="", xlab=""*) plot.order = (1:12)[order(xscale > 0)] for (k in 1:12) { i = plot.order[k] draw.ch(x1[[i]], y1[[i]], x2[[i]], y2[[i]], center.x[i], color = cols[k + 60 * ( i >= 6 & i <= 8 ) + 120 * (i > 8)], alpha[i], xscale[i]) } } ######################################## 2012/12/14 Carlos Ortega <cof@qualityexcellence.es>> #################################### > *win.graph(width=800, height=600)* > for (j in 1:999) { > for (j in 1:999) { > th = th - pi/120 > center.x = 3 + 5 * cos(th) > cols = c(cols[-1], cols[1]) > alpha = 0.1 + (50 * (1 - sin(th)))/100 > alpha = ifelse(alpha > 1, 1, alpha) > xscale = -sin(th) * 1.2 > plot(1, xlim = c(-2, 8), ylim = c(-2.5, 3.5), type = "n", *axes=F, > ylab="", xlab=""*) > plot.order = (1:12)[order(xscale > 0)] > for (k in 1:12) { > i = plot.order[k] > draw.ch(x1[[i]], y1[[i]], x2[[i]], y2[[i]], center.x[i], > color = cols[k + 60 * ( i >= 6 & i <= 8 ) + 120 * > (i > 8)], alpha[i], xscale[i]) > } > } > > > > #################################### >-- Saludos, Carlos Ortega www.qualityexcellence.es [[alternative HTML version deleted]]
miguel.angel.rodriguez.muinos en sergas.es
2012-Dec-14 11:58 UTC
[R-es] Feliz Navidad (R code)
Por cierto... NO LO HE HECHO YO, eh? Esta es la fuente... http://experienceinstatistics.blogspot.com.es/2010/12/feliz-navidad-con-r.html Un Saludo, Miguel. De: Carlos Ortega [mailto:cof@qualityexcellence.es] Enviado el: viernes, 14 de diciembre de 2012 12:49 Para: Rodríguez Muíños, Miguel Ángel CC: Lista R Asunto: Re: [R-es] Feliz Navidad (R code) Uf, disculpad del copy&paste introduje un bucle adicional. Este es el código correcto... ########################################### win.graph(width=800, height=600) for (j in 1:999) { th = th - pi/120 center.x = 3 + 5 * cos(th) cols = c(cols[-1], cols[1]) alpha = 0.1 + (50 * (1 - sin(th)))/100 alpha = ifelse(alpha > 1, 1, alpha) xscale = -sin(th) * 1.2 plot(1, xlim = c(-2, 8), ylim = c(-2.5, 3.5), type = "n", axes=F, ylab="", xlab="") plot.order = (1:12)[order(xscale > 0)] for (k in 1:12) { i = plot.order[k] draw.ch<http://draw.ch>(x1[[i]], y1[[i]], x2[[i]], y2[[i]], center.x[i], color = cols[k + 60 * ( i >= 6 & i <= 8 ) + 120 * (i > 8)], alpha[i], xscale[i]) } } ######################################## 2012/12/14 Carlos Ortega <cof@qualityexcellence.es<mailto:cof@qualityexcellence.es>> #################################### win.graph(width=800, height=600) for (j in 1:999) { for (j in 1:999) { th = th - pi/120 center.x = 3 + 5 * cos(th) cols = c(cols[-1], cols[1]) alpha = 0.1 + (50 * (1 - sin(th)))/100 alpha = ifelse(alpha > 1, 1, alpha) xscale = -sin(th) * 1.2 plot(1, xlim = c(-2, 8), ylim = c(-2.5, 3.5), type = "n", axes=F, ylab="", xlab="") plot.order = (1:12)[order(xscale > 0)] for (k in 1:12) { i = plot.order[k] draw.ch<http://draw.ch>(x1[[i]], y1[[i]], x2[[i]], y2[[i]], center.x[i], color = cols[k + 60 * ( i >= 6 & i <= 8 ) + 120 * (i > 8)], alpha[i], xscale[i]) } } #################################### -- Saludos, Carlos Ortega www.qualityexcellence.es<http://www.qualityexcellence.es> ________________________________ Nota: A información contida nesta mensaxe e os seus posibles documentos adxuntos é privada e confidencial e está dirixida únicamente ó seu destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, por favor elimínea. A distribución ou copia desta mensaxe non está autorizada. Nota: La información contenida en este mensaje y sus posibles documentos adjuntos es privada y confidencial y está dirigida únicamente a su destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, por favor elimínelo. La distribución o copia de este mensaje no está autorizada. See more languages: http://www.sergas.es/aviso_confidencialidad.htm [[alternative HTML version deleted]]
O podrias modificar un poco el codigo en demo(''Xmas'') de animation: n <- length(speed <- runif(angle <- runif(x <- strsplit("FELIZ NAVIDAD", "")[[1]], 0, 360), 0, 15)) x11(width = 10, height = 3) par(mar = rep(0, 4), bg = "white") for (j in 1:1000) { angle = angle + speed dev.hold() plot.new() plot.window(c(1, n), c(0, 1)) for (i in 1:n) text(i, 0.5, x[i], srt = angle[i], cex = runif(1, 1, 4), col = sample(colors(), 1)) ani.pause(0.02) } Saludos, Jorge.- On Fri, Dec 14, 2012 at 10:48 PM, Carlos Ortega <> wrote:> Uf, disculpad del copy&paste introduje un bucle adicional. > > Este es el código correcto... > > ########################################### > *win.graph(width=800, height=600)* > for (j in 1:999) { > th = th - pi/120 > center.x = 3 + 5 * cos(th) > cols = c(cols[-1], cols[1]) > alpha = 0.1 + (50 * (1 - sin(th)))/100 > alpha = ifelse(alpha > 1, 1, alpha) > xscale = -sin(th) * 1.2 > plot(1, xlim = c(-2, 8), ylim = c(-2.5, 3.5), type = "n",* axes=F, > ylab="", xlab=""*) > plot.order = (1:12)[order(xscale > 0)] > for (k in 1:12) { > i = plot.order[k] > draw.ch(x1[[i]], y1[[i]], x2[[i]], y2[[i]], center.x[i], > color = cols[k + 60 * ( i >= 6 & i <= 8 ) + 120 * > (i > 8)], alpha[i], xscale[i]) > } > } > ######################################## > > > > > 2012/12/14 Carlos Ortega <> > > > #################################### > > *win.graph(width=800, height=600)* > > for (j in 1:999) { > > for (j in 1:999) { > > th = th - pi/120 > > center.x = 3 + 5 * cos(th) > > cols = c(cols[-1], cols[1]) > > alpha = 0.1 + (50 * (1 - sin(th)))/100 > > alpha = ifelse(alpha > 1, 1, alpha) > > xscale = -sin(th) * 1.2 > > plot(1, xlim = c(-2, 8), ylim = c(-2.5, 3.5), type = "n", *axes=F, > > ylab="", xlab=""*) > > plot.order = (1:12)[order(xscale > 0)] > > for (k in 1:12) { > > i = plot.order[k] > > draw.ch(x1[[i]], y1[[i]], x2[[i]], y2[[i]], center.x[i], > > color = cols[k + 60 * ( i >= 6 & i <= 8 ) + 120 * > > (i > 8)], alpha[i], xscale[i]) > > } > > } > > > > > > > > #################################### > > > > > > -- > Saludos, > Carlos Ortega > www.qualityexcellence.es > > [[alternative HTML version deleted]] > > > _______________________________________________ > R-help-es mailing list > R-help-es@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-help-es > >[[alternative HTML version deleted]]
Gracias Miguel. Felicidades para ti también. Un abrazo. 2012/12/14 <miguel.angel.rodriguez.muinos@sergas.es>> f.x = c(0.193,0.703,0.703,0.295,0.295,0.703,0.703,0.295,0.295,0.193,0.193) > f.y = c(0.935,0.935,0.835,0.835,0.575,0.575,0.475,0.475,0.063,0.063,0.935) > e.x = c(0.222, 0.787, 0.787, 0.324, 0.324, 0.757, 0.757, 0.324, > 0.324,0.804, 0.804, 0.222) > e.y = c(0.935, 0.935, 0.834, 0.834, 0.564, 0.564, 0.464, 0.464, > 0.163,0.163, 0.063, 0.063) > l.x = c(0.222,0.324,0.324,0.804,0.804,0.222) > l.y = c(0.935,0.935,0.163,0.163,0.063,0.063) > a1.x = c(0.433, 0.546, 0.865, 0.746, 0.656, 0.328, 0.242, 0.136) > a1.y = c(0.935, 0.935, 0.063, 0.063, 0.326, 0.326, 0.063, 0.063) > a2.x = c(0.488, 0.629, 0.355) > a2.y = c(0.841, 0.418, 0.418) > n.x = c(0.189, 0.295, 0.707, 0.707, 0.804, 0.804, 0.701, 0.287, 0.287, > 0.189) > n.y = c(0.935, 0.935, 0.248, 0.935, 0.935, 0.063, 0.063, 0.747, 0.063, > 0.063) > d.x = c(0.218,0.56,0.56,0.56,0.56,0.32,0.218,0.32,0.32) > d.y = c(0.935,0.933,0.832,0.518,0.418,0.063,0.063,0.518,0.834) > d.cir.th = seq(pi/2, -pi/2, length.out = 50) > d1.cir.x = 0.32 + 0.515 * cos(d.cir.th) > d1.cir.y = 0.499 + 0.436 * sin(d.cir.th) > d2.cir.x = 0.32 + 0.4147 * cos(d.cir.th) > d2.cir.y = 0.499 + 0.3 * sin(d.cir.th) > d1.x = c(0.218, d1.cir.x, 0.32, 0.218) > d1.y = c(0.935, d1.cir.y, 0.063, 0.063) > d2.x = c(0.32, d2.cir.x, 0.32) > d2.y = c(0.799, d2.cir.y,0.199) > n.x = c(0.189, 0.295, 0.707, 0.707, 0.804, 0.804, 0.701, 0.287, 0.287, > 0.189) > n.y = c(0.935, 0.935, 0.248, 0.935, 0.935, 0.063, 0.063, 0.747, 0.063, > 0.063) > i.x = c(0.189, 0.295, 0.295, 0.189, 0.189) > i.y = c(0.935, 0.935, 0.063, 0.063, 0.935) > e.x = c(0.222, 0.787, 0.787, 0.324, 0.324, 0.757, 0.757, 0.324, > 0.324,0.804, 0.804, 0.222) > e.y = c(0.935, 0.935, 0.834, 0.834, 0.564, 0.564, 0.464, 0.464, > 0.163,0.163, 0.063, 0.063) > z.x = c(0.222,0.787,0.787,0.322,0.804,0.804,0.222,0.222,0.687,0.222) > z.y = c(0.935,0.935,0.834,0.163,0.163,0.063,0.063,0.163,0.834,0.834) > v.x = c(0.136, 0.259, 0.496, 0.734, 0.853, 0.543, 0.441) > v.y = c(0.935, 0.935, 0.163, 0.935, 0.935, 0.063, 0.063) > draw.ch = function(x1, y1, x2 = NULL, y2 = NULL, center.x, > color, alpha, xscale) { > rgb.col = col2rgb(color)/255 > x1 = x1 * xscale + center.x - 0.5 * xscale > x2 = x2 * xscale + center.x - 0.5 * xscale > polygon(x1, y1, col = rgb(rgb.col[1], rgb.col[2], rgb.col[3], > alpha = alpha), border = NA) > # polygon(x2, y2, col = "black", border = NA) > polygon(x2, y2, col = "white", border = NA) > } > x1 = list(f.x, e.x, l.x, i.x, z.x, n.x, a1.x,v.x,i.x,d1.x,a1.x,d1.x) > y1 = list(f.y,e.y,l.y,i.y,z.y,n.y,a1.y,v.y,i.y,d1.y,a1.y,d1.y) > x2 = list(NULL,NULL,NULL,NULL,NULL,NULL,a2.x,NULL,NULL,d2.x,a2.x,d2.x) > y2 = list(NULL,NULL,NULL,NULL,NULL,NULL,a2.y,NULL,NULL,d2.y,a2.y,d2.y) > th = seq(pi/6, 2 * pi, length.out = 12) > cols = rainbow(200) > for (j in 1:999) { > th = th - pi/120 > center.x = 3 + 5 * cos(th) > cols = c(cols[-1], cols[1]) > alpha = 0.1 + (50 * (1 - sin(th)))/100 > alpha = ifelse(alpha > 1, 1, alpha) > xscale = -sin(th) * 1.2 > plot(1, xlim = c(-2, 8), ylim = c(-2.5, 3.5), type = "n") > plot.order = (1:12)[order(xscale > 0)] > for (k in 1:12) { > i = plot.order[k] > draw.ch(x1[[i]], y1[[i]], x2[[i]], y2[[i]], center.x[i], > color = cols[k + 60 * ( i >= 6 & i <= 8 ) + 120 * > (i > 8)], alpha[i], xscale[i]) > } > } > > > ## Un Saludo, > ## ________________________________________________________ > ## Miguel Ángel Rodríguez Muíños > ## @mianromu > ## Dirección Xeral de Innovación e Xestión da Saúde Pública > ## Consellería de Sanidade > ## Xunta de Galicia > ## > ## http://dxsp.sergas.es > > > > > > > > > > > > > > > > > > Nota: A información contida nesta mensaxe e os seus posibles documentos > adxuntos é privada e confidencial e está dirixida únicamente ó seu > destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, > por favor elimínea. A distribución ou copia desta mensaxe non está > autorizada. > > Nota: La información contenida en este mensaje y sus posibles documentos > adjuntos es privada y confidencial y está dirigida únicamente a su > destinatario/a. Si usted no es el/la destinatario/a original de este > mensaje, por favor elimínelo. La distribución o copia de este mensaje no > está autorizada. > > See more languages: http://www.sergas.es/aviso_confidencialidad.htm > > _______________________________________________ > R-help-es mailing list > R-help-es@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-help-es >-- «But Gwindor answered: ''The doom lies in yourself, not in your name.''» JRR Tolkien [[alternative HTML version deleted]]
Muchísimas gracias Tiene dos cosas valorables, por un lado el utilizar algún programa que dibuja y coloca arreglitos lindos, estilo diseño gráfico, visualmente es más potente pero no tiene esa delicadeza de hacerlo con las herramientas de todos los días, creo que como saludo es mucho más cálido regalar el código que lleva tiempo antes de lo automático que se logra con los movimientos de mouse (o dedos en celulares, tablet). Lo segundo que valoro dentro del código es: ¿como escribieron esos valores para las letras (f.x=c(0.193,0.....)? Hay que hacerlo, si con apretar solo una tecla se obtiene el carácter correspondiente, te tienen que gustar los números o busca un psiquiatra. Por último un pedido a la lista, si deseamos una Navidad como Dios manda, tengamos cuidado a quién le enviamos el código de saludo navideño en R porque por culpa de Miguel nos internan a todos en una clínica para salud mental. Javier Marcuzzi -----Mensaje original----- From: miguel.angel.rodriguez.muinos en sergas.es Sent: Friday, December 14, 2012 8:10 AM To: r-help-es en r-project.org Subject: [R-es] Feliz Navidad (R code) f.x = c(0.193,0.703,0.703,0.295,0.295,0.703,0.703,0.295,0.295,0.193,0.193) f.y = c(0.935,0.935,0.835,0.835,0.575,0.575,0.475,0.475,0.063,0.063,0.935) e.x = c(0.222, 0.787, 0.787, 0.324, 0.324, 0.757, 0.757, 0.324, 0.324,0.804, 0.804, 0.222) e.y = c(0.935, 0.935, 0.834, 0.834, 0.564, 0.564, 0.464, 0.464, 0.163,0.163, 0.063, 0.063) l.x = c(0.222,0.324,0.324,0.804,0.804,0.222) l.y = c(0.935,0.935,0.163,0.163,0.063,0.063) a1.x = c(0.433, 0.546, 0.865, 0.746, 0.656, 0.328, 0.242, 0.136) a1.y = c(0.935, 0.935, 0.063, 0.063, 0.326, 0.326, 0.063, 0.063) a2.x = c(0.488, 0.629, 0.355) a2.y = c(0.841, 0.418, 0.418) n.x = c(0.189, 0.295, 0.707, 0.707, 0.804, 0.804, 0.701, 0.287, 0.287, 0.189) n.y = c(0.935, 0.935, 0.248, 0.935, 0.935, 0.063, 0.063, 0.747, 0.063, 0.063) d.x = c(0.218,0.56,0.56,0.56,0.56,0.32,0.218,0.32,0.32) d.y = c(0.935,0.933,0.832,0.518,0.418,0.063,0.063,0.518,0.834) d.cir.th = seq(pi/2, -pi/2, length.out = 50) d1.cir.x = 0.32 + 0.515 * cos(d.cir.th) d1.cir.y = 0.499 + 0.436 * sin(d.cir.th) d2.cir.x = 0.32 + 0.4147 * cos(d.cir.th) d2.cir.y = 0.499 + 0.3 * sin(d.cir.th) d1.x = c(0.218, d1.cir.x, 0.32, 0.218) d1.y = c(0.935, d1.cir.y, 0.063, 0.063) d2.x = c(0.32, d2.cir.x, 0.32) d2.y = c(0.799, d2.cir.y,0.199) n.x = c(0.189, 0.295, 0.707, 0.707, 0.804, 0.804, 0.701, 0.287, 0.287, 0.189) n.y = c(0.935, 0.935, 0.248, 0.935, 0.935, 0.063, 0.063, 0.747, 0.063, 0.063) i.x = c(0.189, 0.295, 0.295, 0.189, 0.189) i.y = c(0.935, 0.935, 0.063, 0.063, 0.935) e.x = c(0.222, 0.787, 0.787, 0.324, 0.324, 0.757, 0.757, 0.324, 0.324,0.804, 0.804, 0.222) e.y = c(0.935, 0.935, 0.834, 0.834, 0.564, 0.564, 0.464, 0.464, 0.163,0.163, 0.063, 0.063) z.x = c(0.222,0.787,0.787,0.322,0.804,0.804,0.222,0.222,0.687,0.222) z.y = c(0.935,0.935,0.834,0.163,0.163,0.063,0.063,0.163,0.834,0.834) v.x = c(0.136, 0.259, 0.496, 0.734, 0.853, 0.543, 0.441) v.y = c(0.935, 0.935, 0.163, 0.935, 0.935, 0.063, 0.063) draw.ch = function(x1, y1, x2 = NULL, y2 = NULL, center.x, color, alpha, xscale) { rgb.col = col2rgb(color)/255 x1 = x1 * xscale + center.x - 0.5 * xscale x2 = x2 * xscale + center.x - 0.5 * xscale polygon(x1, y1, col = rgb(rgb.col[1], rgb.col[2], rgb.col[3], alpha = alpha), border = NA) # polygon(x2, y2, col = "black", border = NA) polygon(x2, y2, col = "white", border = NA) } x1 = list(f.x, e.x, l.x, i.x, z.x, n.x, a1.x,v.x,i.x,d1.x,a1.x,d1.x) y1 = list(f.y,e.y,l.y,i.y,z.y,n.y,a1.y,v.y,i.y,d1.y,a1.y,d1.y) x2 = list(NULL,NULL,NULL,NULL,NULL,NULL,a2.x,NULL,NULL,d2.x,a2.x,d2.x) y2 = list(NULL,NULL,NULL,NULL,NULL,NULL,a2.y,NULL,NULL,d2.y,a2.y,d2.y) th = seq(pi/6, 2 * pi, length.out = 12) cols = rainbow(200) for (j in 1:999) { th = th - pi/120 center.x = 3 + 5 * cos(th) cols = c(cols[-1], cols[1]) alpha = 0.1 + (50 * (1 - sin(th)))/100 alpha = ifelse(alpha > 1, 1, alpha) xscale = -sin(th) * 1.2 plot(1, xlim = c(-2, 8), ylim = c(-2.5, 3.5), type = "n") plot.order = (1:12)[order(xscale > 0)] for (k in 1:12) { i = plot.order[k] draw.ch(x1[[i]], y1[[i]], x2[[i]], y2[[i]], center.x[i], color = cols[k + 60 * ( i >= 6 & i <= 8 ) + 120 * (i > 8)], alpha[i], xscale[i]) } } ## Un Saludo, ## ________________________________________________________ ## Miguel Ángel Rodríguez Muíños ## @mianromu ## Dirección Xeral de Innovación e Xestión da Saúde Pública ## Consellería de Sanidade ## Xunta de Galicia ## ## http://dxsp.sergas.es Nota: A información contida nesta mensaxe e os seus posibles documentos adxuntos é privada e confidencial e está dirixida únicamente ó seu destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, por favor elimínea. A distribución ou copia desta mensaxe non está autorizada. Nota: La información contenida en este mensaje y sus posibles documentos adjuntos es privada y confidencial y está dirigida únicamente a su destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, por favor elimínelo. La distribución o copia de este mensaje no está autorizada. See more languages: http://www.sergas.es/aviso_confidencialidad.htm _______________________________________________ R-help-es mailing list R-help-es en r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es