CC BY-NC-ND 3.0
plotplotplotplotplotplotplot(x = rep(1:5, 5), y = rep(1:5, each = 5),
pch = 1:25, xlab = "", ylab = "", cex = 2)
text(x = rep(seq(1:5), 5), y = rep(seq(1:5), each = 5),
labels = 1:25, pos = 4)plotplot(x = myX, y = myY,
pch = c("a", "@", "#", "1", "=", "-", "_", "o", "O", "0",
letters[1:15]), cex = 2)plotplotplot(x = myX, y = myY,
cex = seq(from = 0.5, to = 5, length.out = 100),
pch = 16,
col = sample(colors(), 100))plotplot## myX myY
## 1 1.54652775 0.98203127
## 2 1.92331768 0.60806081
## 3 0.08341063 0.02792164
## 4 0.58529863 0.47730264
## 5 1.68783551 -0.13917972
## 6 1.17642085 -0.19342129
## 7 0.06981720 -1.26890972
## 8 2.38322205 -0.31977800
## 9 0.26150711 -0.05256700
## 10 -0.37503628 -1.31416568
## 11 0.85857806 1.75393012
## 12 -0.81217396 0.23898354
## 13 0.74970325 0.25122926
## 14 0.10556934 1.34485148
## 15 0.16730426 -1.43159322
## 16 0.76798213 -2.01158330
## 17 1.87526397 -1.35214636
## 18 -0.57788954 -0.06158261
## 19 -1.24514382 0.85183678
## 20 -2.09958731 0.45206061
plotplot## myX myY myCol
## 20 -2.0995873 0.4520606 #0000FF
## 21 -2.0194602 0.4392399 #0505F9
## 92 -1.8269490 1.6016332 #0A0AF4
## 52 -1.6992173 -0.4633641 #0F0FEF
## 98 -1.6970580 -0.4777775 #1414EA
## 64 -1.6641388 -0.4515215 #1919E5
## 68 -1.6381789 -0.4403694 #1E1EE0
## 54 -1.6153006 -0.0384538 #2424DA
## 34 -1.4227258 1.2343830 #2929D5
## 43 -1.3993424 0.1400011 #2E2ED0
## 84 -1.3755416 -0.9518039 #3333CB
## 63 -1.3416515 -0.6004861 #3838C6
## 19 -1.2451438 0.8518368 #3D3DC1
## 87 -1.1346758 -0.5575879 #4242BC
## 90 -1.0717999 0.2259167 #4848B6
## 89 -1.0340338 0.4557486 #4D4DB1
## 51 -0.9702982 -0.8304358 #5252AC
## 26 -0.9616053 -1.3683735 #5757A7
## 71 -0.9427434 0.8052766 #5C5CA2
## 12 -0.8121740 0.2389835 #61619D
plotplot## myX myY myCol myCex
## 83 1.06637947 -2.5356713 #FF7100 0.5000000
## 16 0.76798213 -2.0115833 #FF9F00 0.5454545
## 57 -0.12255446 -1.9494928 #D3D32B 0.5909091
## 82 -0.17940086 -1.9118695 #C3C33B 0.6363636
## 15 0.16730426 -1.4315932 #FFE700 0.6818182
## 37 0.10491443 -1.4188780 #FFF200 0.7272727
## 26 -0.96160525 -1.3683735 #5757A7 0.7727273
## 17 1.87526397 -1.3521464 #FF1400 0.8181818
## 10 -0.37503628 -1.3141657 #9A9A64 0.8636364
## 7 0.06981720 -1.2689097 #F7F707 0.9090909
## 96 0.08490146 -1.0868609 #FFFC00 0.9545455
## 31 1.77603144 -1.0242393 #FF1900 1.0000000
## 84 -1.37554156 -0.9518039 #3333CB 1.0454545
## 51 -0.97029818 -0.8304358 #5252AC 1.0909091
## 88 -0.26626962 -0.7749495 #AFAF4F 1.1363636
## 77 0.73395525 -0.7674954 #FFA900 1.1818182
## 35 0.84970336 -0.7146479 #FF8000 1.2272727
## 65 -0.23558603 -0.6868824 #B4B44A 1.2727273
## 59 -0.76198487 -0.6856236 #676797 1.3181818
## 60 0.31187308 -0.6089887 #FFD300 1.3636364
plotplot(x = dfGraph$myX, y = dfGraph$myY,
cex = dfGraph$myCex, pch = 16, col = dfGraph$myCol,
xlab = "", ylab = "")plotplot## myX myY myCol myCex grupo
## 83 1.06637947 -2.5356713 #FF7100 0.5000000 e
## 16 0.76798213 -2.0115833 #FF9F00 0.5454545 b
## 57 -0.12255446 -1.9494928 #D3D32B 0.5909091 b
## 82 -0.17940086 -1.9118695 #C3C33B 0.6363636 c
## 15 0.16730426 -1.4315932 #FFE700 0.6818182 b
## 37 0.10491443 -1.4188780 #FFF200 0.7272727 e
## 26 -0.96160525 -1.3683735 #5757A7 0.7727273 a
## 17 1.87526397 -1.3521464 #FF1400 0.8181818 a
## 10 -0.37503628 -1.3141657 #9A9A64 0.8636364 e
## 7 0.06981720 -1.2689097 #F7F707 0.9090909 c
## 96 0.08490146 -1.0868609 #FFFC00 0.9545455 b
## 31 1.77603144 -1.0242393 #FF1900 1.0000000 a
## 84 -1.37554156 -0.9518039 #3333CB 1.0454545 b
## 51 -0.97029818 -0.8304358 #5252AC 1.0909091 b
## 88 -0.26626962 -0.7749495 #AFAF4F 1.1363636 e
## 77 0.73395525 -0.7674954 #FFA900 1.1818182 e
## 35 0.84970336 -0.7146479 #FF8000 1.2272727 a
## 65 -0.23558603 -0.6868824 #B4B44A 1.2727273 d
## 59 -0.76198487 -0.6856236 #676797 1.3181818 b
## 60 0.31187308 -0.6089887 #FFD300 1.3636364 e
plot## 'data.frame': 100 obs. of 5 variables:
## $ myX : num 1.066 0.768 -0.123 -0.179 0.167 ...
## $ myY : num -2.54 -2.01 -1.95 -1.91 -1.43 ...
## $ myCol: chr "#FF7100" "#FF9F00" "#D3D32B" "#C3C33B" ...
## $ myCex: num 0.5 0.545 0.591 0.636 0.682 ...
## $ grupo: Factor w/ 5 levels "a","b","c","d",..: 5 2 2 3 2 5 1 1 5 3 ...
plotplot(x = dfGraph$myX, y = dfGraph$myY,
pch = 16, xlab = "", ylab = "",
col = as.numeric(dfGraph$grupo))plotplot(x = dfGraph$myX, y = dfGraph$myY, pch = 16, xlab = "",
ylab = "", cex = 2, col = as.numeric(dfGraph$grupo))
legend("topleft", fill = seq_along(levels(dfGraph$grupo)),
legend = levels(dfGraph$grupo))plotplot(x = dfGraph$myX, y = dfGraph$myY,
pch = as.numeric(dfGraph$grupo), xlab = "", ylab = "",
cex = 2, col = as.numeric(dfGraph$grupo))
legend("topleft", pch = seq_along(levels(dfGraph$grupo)),
legend = levels(dfGraph$grupo),
col = seq_along(levels(dfGraph$grupo)))plotplotplotplotplotplotplotplotplotplot(x = myX, y = myY, type = 'n')
grid(lwd = 3, lty = 1)
points(x = myX, y = myY, type = "l", lwd = 2)plotplotplotop <- par(no.readonly = TRUE)
par(mfrow = c(1, 2))
plot(x = myX, y = myY, type = 'l', lwd = 2)
grid(lwd = 3, lty = 1)
plot(x = myX, y = myY, type = 'l', lwd = 2,
panel.first = grid(lwd = 3, lty = 1))plotplotpar(mfrow = c(1, 2), mar = c(2, 2, 1, 1))
plot(x = myX, y = myY, type = 'l', lwd = 2)
grid(lwd = 3, lty = 1)
plot(x = myX, y = myY, type = 'l', lwd = 2,
panel.first = grid(lwd = 3, lty = 1))plotplotpar(mfrow = c(2, 2), mar = c(2, 2, 1, 1))
graph4 <- lapply(1:4, function(i){
plot(x = rnorm(100),
y = rnorm(100),
col = i, pch = 16)
})plotplotplot(x = myX, y = myY, type = 'l', lwd = 2)
abline(h = mean(myY), lwd = 1, lty = 2)
abline(v = myX[myY == min(myY)], col = 4, lty = 2)
abline(v = myX[myY == max(myY)], col = 2, lty = 2)histhisthistpar(mfrow = c(2, 2), mar = c(2, 2, 1, 1))
tr <- lapply(1:4, function(i){
hist(myX[[i]], col = heat.colors(15),
main = myTitle[i]
)
})histhistmyX <- rnorm(1000)
par(mfrow = c(1, 2), mar = c(1, 1, 1, 1))
hist(myX, axes = FALSE, col = rainbow(100))
hist(myX, axes = FALSE, nclass = 100, col = rainbow(100))histbarplotbarplotbarplotbarplot# pkgCheck("palettesForR")
myX <- rnorm(3, mean = 10)
barplot(myX, names.arg = c("A", "B", "C"), col = Cool_gpl)barplotpar(mar = c(1, 1, 1, 1))
myX <- matrix(c(4, 5, 8, 4, 6, 2, 3, 4, 5), nrow = 3)
barplot(myX, axes = FALSE, col = Pastels_gpl[1:3])barplotpar(mar = c(1, 1, 1, 1))
barplot(myX, axes = FALSE, col = Pastels_gpl[1:3],
beside = TRUE, legend.text = c("A", "B", "C"))plot + barplotplot + barplotn <- 50
myX <- rnorm(n)
myY <- rnorm(n)
myCol <- c(2, sample(c(4, 2), size = (n - 1), replace = TRUE))
myColors <- colorRampPalette(c("blue", "red"))(100)
head(data.frame(myX, myY, myCol))## myX myY myCol
## 1 -0.7761458 -1.24459376 2
## 2 0.1938932 0.04129434 4
## 3 -0.9152905 -1.07962279 4
## 4 -0.9595136 2.58892371 2
## 5 1.7527446 -0.32798150 2
## 6 1.8579302 -0.05269327 2
plot + barplot## [1] (-1,0] (0,1] (-1,0] (-1,0] (1,2] (1,2] (0,1] (0,1]
## [9] (-2,-1] (0,1] (0,1] (0,1] (-1,0] (-2,-1] (0,1] (0,1]
## [17] (0,1] (0,1] (0,1] (-3,-2] (0,1] (0,1] (0,1] (0,1]
## [25] (-1,0] (-1,0] (1,2] (-1,0] (-1,0] (0,1] (-1,0] (-1,0]
## [33] (-2,-1] (0,1] (-1,0] (0,1] (-2,-1] (0,1] (0,1] (0,1]
## [41] (0,1] (0,1] (0,1] (0,1] (0,1] (-2,-1] (-2,-1] (0,1]
## [49] (-1,0] (1,2]
## Levels: (-4,-3] (-3,-2] (-2,-1] (-1,0] (0,1] (1,2] (2,3] (3,4]
plot + barplot## myXCut
## myCol (-4,-3] (-3,-2] (-2,-1] (-1,0] (0,1] (1,2] (2,3] (3,4]
## 2 0 0 5 5 9 4 0 0
## 4 0 1 1 7 18 0 0 0
plot + barplotxCol <- round(
myXCutCol[1,] / (myXCutCol[1,] + myXCutCol[2,]) * 100
)
xCol[is.na(xCol) | xCol == 0] <- 1
yCol <- round(
myYCutCol[1,] / (myYCutCol[1,] + myYCutCol[2,]) * 100
)
yCol[is.na(yCol) | yCol == 0] <- 1
print(xCol)## (-4,-3] (-3,-2] (-2,-1] (-1,0] (0,1] (1,2] (2,3] (3,4]
## 1 1 83 42 33 100 1 1
plot + barplotpar(mar = c(2, 3, 1, 1))
layout(matrix(c(1, 1, 0,
2, 2, 3,
2, 2, 3), ncol = 3, byrow = TRUE))
barplot(table(myXCut), las = 1, col = myColors[xCol])
plot(x = myX, y = myY, col = myCol, pch = 16,
xlim = c(-4, 4), ylim = c(-4, 4), cex = 1.5,
panel.first = grid())
barplot(table(myYCut), las = 1, horiz = TRUE,
col = myColors[yCol])plot + barplotplot + barplotgraphBarplotCol <- function(n){
myX <- rnorm(n)
myY <- rnorm(n)
myCol <- c(2, sample(c(4, 2), size = (n - 1), replace = TRUE))
myColors <- colorRampPalette(c("blue", "red"))(100)
myYCut <- cut(myY, breaks = -4:4)
myXCut <- cut(myX, breaks = -4:4)
myYCutCol <- table(myCol, myYCut)
myXCutCol <- table(myCol, myXCut)
xCol <- round(
myXCutCol[1,] / (myXCutCol[1,] + myXCutCol[2,]) * 100
)
xCol[is.na(xCol) | xCol == 0] <- 1
yCol <- round(
myYCutCol[1,] / (myYCutCol[1,] + myYCutCol[2,]) * 100
)
yCol[is.na(yCol) | yCol == 0] <- 1
op <- par(no.readonly = TRUE)
par(mar = c(2, 3, 1, 1))
layout(matrix(c(1, 1, 0,
2, 2, 3,
2, 2, 3), ncol = 3, byrow = TRUE))
barplot(table(myXCut), las = 1, col = myColors[xCol])
plot(x = myX, y = myY, col = myCol, pch = 16,
xlim = c(-4, 4), ylim = c(-4, 4), cex = 1.5,
panel.first = grid())
barplot(table(myYCut), las = 1, horiz = TRUE,
col = myColors[yCol])
par(op)
}plot + barplotplot + barplotplot + barplotplot + barplotboxplotboxplotboxplotboxplotboxplotboxplotboxplotboxplotboxplotboxplotboxplotboxplot