febrero 10, 2013

Muestra de gráficos en R

R contiene una plenitud de opciones para gráficos. Los siguientes gráficos y símbolos se encuentran en la base de R—sus sintaxis se puede llamar al escribir: example(points)

# Muestra de graficos en R
example (points)

points> require(stats) # for rnorm

points> plot(-4:4, -4:4, type = "n")  # setting up coord. system
plot of chunk unnamed-chunk-1

points> points(rnorm(200), rnorm(200), col = "red")

points> points(rnorm(100)/2, rnorm(100)/2, col = "blue", cex = 1.5)

points> op <- bg="light blue" par="" points=""> x <- 2="" len="51)" pi="" points="" seq=""> ## something "between type='b' and type='o'":
points> plot(x, sin(x), type = "o", pch = 21, bg = par("bg"), col = "blue", cex = .6,
points+  main = 'plot(..., type="o", pch=21, bg=par("bg"))')
plot of chunk unnamed-chunk-1

points> par(op)

points> ## Not run: 
points> ##D ## The figure was produced by calls like
points> ##D png("pch.png", height = 0.7, width = 7, res = 100, units = "in")
points> ##D par(mar = rep(0,4))
points> ##D plot(c(-1, 26), 0:1, type = "n", axes = FALSE)
points> ##D text(0:25, 0.6, 0:25, cex = 0.5)
points> ##D points(0:25, rep(0.3, 26), pch = 0:25, bg = "grey")
points> ## End(Not run)
points> 
points> ##-------- Showing all the extra & some char graphics symbols ---------
points> pchShow <- .device="=" 0:="" 26="" 3="" :="" amp="" and="" as.list="" bg="gold" both="" c="" cex=",
points+                         cex," cextext="1.2," col="red3" coltext="brown" dd="" extras="" floor="" for="" function="" good="" if="" integers="" ipch="" ix="" iy="" k-1="" k="" length="" list="" main="paste(" nex="" np-1="" np="" o="" pch="" plot="" points="" postscript="" range="" rx="" ry="" sqrt="" strings="" symbols="" with="" x11=""> 0) pch[26+ 1:nex] <- 1:np="" :="" a="" abline="" as.list="" available="" axes="FALSE," bg="bg," cex="cex)" cextext="" col="col," colored="" extras="" for="" h="iy," i="" if="" in="" interior="" ix="" iy="" lty="dotted" main="main)" pc="" pch="pc," plot="" points="" rx="" ry="" symbols="" type="n" v="ix," where="" with="" xlab="" ylab=""> 0)
points+           text(ix[i] - 0.3, iy[i], pc, col = coltext, cex = cextext)
points+     }
points+   }

points> pchShow()
plot of chunk unnamed-chunk-1

points> pchShow(c("o","O","0"), cex = 2.5)
plot of chunk unnamed-chunk-1

points> pchShow(NULL, cex = 4, cextext = 0, main = NULL)
plot of chunk unnamed-chunk-1

points> ## No test: 
points> ## ------------ test code for various pch specifications -------------
points> # Try this in various font families (including Hershey)
points> # and locales.  Use sign = -1 asserts we want Latin-1.
points> # Standard cases in a MBCS locale will not plot the top half.
points> TestChars <- -1="" ...="" 160:254="" 160:255="" 17="" 1="" 32:126="" 32:255="" 5="" c="" else="" font="font,...))" for="" function="" grid="" i="" if="" in="" l10n_info="" lty="1)" main="sprintf(" mb="" mtext="" par="" paste="" pch="sign*i," plot="" points="" pty="s" r="" sign="" try="" type="n" xaxs="i" xlab="" yaxs="i" ylab=""> TestChars()
Warning: font width unknown for character 0x7f
Warning: font metrics unknown for character 0x7f
Warning: font width unknown for character 0x81
Warning: font metrics unknown for character 0x81
Warning: font width unknown for character 0x8d
Warning: font metrics unknown for character 0x8d
Warning: font width unknown for character 0x8f
Warning: font metrics unknown for character 0x8f
Warning: font width unknown for character 0x90
Warning: font metrics unknown for character 0x90
Warning: font width unknown for character 0x9d
Warning: font metrics unknown for character 0x9d
plot of chunk unnamed-chunk-1

points> try(TestChars(sign = -1))
plot of chunk unnamed-chunk-1

points> TestChars(font = 5)  # Euro might be at 160 (0+10*16).  Mac OS has apple at 240 (0+15*16).
Warning: font width unknown for character 0xf0
Warning: font metrics unknown for character 0xf0
plot of chunk unnamed-chunk-1

points> try(TestChars(-1, font = 2))  # bold
plot of chunk unnamed-chunk-1

points> ## End(No test)
points> 





No hay comentarios.: