Mostrar datos vs mostrar información.
- stats: Qué mostrar
- geoms: Como mostrar
Mostrar datos vs mostrar información.
geom_abline | geom_density2d | geom_line | geom_ribbon | |
geom_area | geom_density_2d | geom_linerange | geom_rug | |
geom_bar | geom_dotplot | geom_map | geom_segment | |
geom_bin2d | geom_errorbar | geom_path | geom_smooth | |
geom_blank | geom_errorbarh | geom_point | geom_spoke | |
geom_boxplot | geom_freqpoly | geom_pointrange | geom_step | |
geom_contour | geom_hex | geom_polygon | geom_text | |
geom_count | geom_histogram | geom_qq | geom_tile | |
geom_crossbar | geom_hline | geom_quantile | geom_violin | |
geom_curve | geom_jitter | geom_raster | geom_vline | |
geom_density | geom_label | geom_rect |
stat_bin | stat_contour | stat_ellipse | stat_spoke | stat_summary_hex | |
stat_bin2d | stat_count | stat_function | stat_sum | stat_unique | |
stat_bin_2d | stat_density | stat_identity | stat_summary | stat_ydensity | |
stat_binhex | stat_density2d | stat_qq | stat_summary2d | ||
stat_bin_hex | stat_density_2d | stat_quantile | stat_summary_2d | ||
stat_boxplot | stat_ecdf | stat_smooth | stat_summary_bin |
ggplot(mtcars) + aes(y = mpg, x = factor(cyl)) + geom_violin()
ggplot(mtcars) + aes(x = factor(cyl), y = mpg) + geom_dotplot(binaxis = "y", stackdir = "center", binwidth = 1)
ggplot(mtcars) + aes(factor(cyl), mpg) + geom_boxplot()
ggplot(mtcars) + aes(factor(cyl)) + geom_bar(stat = "count")
df <- as.data.frame(table(factor(mtcars$cyl))) ggplot(df) + aes(x = Var1, y = Freq) + geom_bar(stat = "identity")
ggplot(iris) + aes(sample = Petal.Length) + geom_point(stat = "qq")
ggplot(diamonds) + aes(price, depth) + geom_point()
ggplot(diamonds) + aes(price, depth) + geom_bin2d()
ggplot(diamonds) + aes(price, depth, z = table) + geom_bin2d(stat = "summary2d")
#install.packages("hexbin") ggplot(diamonds) + aes(price, depth) + geom_hex(stat = "binhex")
#install.packages("hexbin") ggplot(diamonds) + aes(price, depth, z = table) + stat_summary_hex()
ggplot(mpg) + aes(displ, hwy) + geom_point()
set.seed(43210) ggplot(mpg) + aes(displ, hwy, angle = runif(234, 0, 2*pi)) + geom_point() + geom_spoke(radius = 0.5)
set.seed(86420) ggplot(mpg) + aes(displ, hwy) + geom_jitter()
ggplot(mpg) + aes(displ, hwy) + geom_point() + geom_quantile()
ggplot(mpg) + aes(displ, hwy) + geom_point() + geom_smooth()
set.seed(98765) ggplot(mpg) + aes(displ, hwy) + geom_jitter() + geom_density2d()
ggplot(mpg) + aes(displ, hwy) + geom_point() + geom_path()
ggplot(mpg) + aes(displ, hwy) + geom_point() + geom_rug()
ggplot(mpg) + aes(displ, hwy) + geom_point() + geom_path(stat = "ellipse")
ggplot(mpg) + aes(displ, hwy) + geom_point(stat = "unique")
ggplot(intervalos) + aes(x = names, ymin = q1, ymax = q3, y = med) + geom_crossbar()
ggplot(intervalos) + aes(x = names, ymin = q1, ymax = q3, y = med) + geom_linerange()
ggplot(intervalos) + aes(x = names, ymin = q1, ymax = q3, y = med) + geom_pointrange()
ggplot(intervalos) + aes(x = names, ymin = q1, ymax = q3, y = med) + geom_errorbar()
ggplot(intervalos) + aes(y = names, xmin = q1, xmax = q3, x = med) + geom_errorbarh()
ggplot(intervalos) + aes(x = 1:7, ymin = q1, ymax = q3, y = med) + geom_ribbon(alpha = I(1/3)) + geom_pointrange()
intervalos %>% select(-names) %>% gather(stat, value) %>% ggplot + aes(y = value, x = rep(1:7, 5), fill= stat) + geom_area()
intervalos %>% select(-names) %>% gather(stat, value) %>% ggplot + aes(y = value, x = rep(1:7, 5), colour= stat) + geom_line()
ggplot(mtcars) + aes(x = mpg) + geom_density()
ggplot(mtcars) + aes(x = mpg) + geom_density() + stat_function(fun = dnorm, colour = "red", arg = list(mean = mean(mtcars$mpg), sd = sd(mtcars$mpg)))
ggplot(mtcars) + aes(x = mpg) + geom_freqpoly(binwidth = 2)
ggplot(mtcars) + aes(x = mpg) + geom_histogram(binwidth = 2)
ggplot() + scale_x_continuous(name = "x", limits = c(0,5)) + scale_y_continuous(name = "y", limits = c(0,10)) + scale_linetype(name = "s") + geom_abline(data.example, mapping = aes(slope = vx, intercept = vy, linetype = factor(x))) + geom_hline(data = data.example, mapping = aes(yintercept = vy)) + geom_vline(data = data.example, mapping = aes(xintercept = vy))
ggplot(mtcars) + aes(x = wt, y = mpg) + geom_point() + geom_abline(aes(intercept = a, slope = b), data = df1)
ggplot(mtcars) + aes(x = wt, y = mpg, colour = factor(cyl), size = hp) + geom_blank() + geom_abline(aes(intercept = a, slope = b), data = df1)
ggplot(data.example) + aes(x = x, y = y, xend = x + vx, yend = y + vy) + geom_segment(arrow = arrow(), size = 2, color = "blue")
ggplot(data.example) + aes(xmin = x, ymin = y, xmax = x + vx, ymax = y + vy) + geom_rect(fill = "blue")
data.frame(x = sort(rnorm(47))) %>% ggplot + aes(seq_along(x), x) + geom_step()
data.frame(x = rnorm(100)) %>% ggplot + aes(x) + geom_step(stat = "ecdf")
ggplot(mtcars) + aes(x = wt, y = mpg, label = rownames(mtcars)) + geom_text()
require("colmaps") map_df <- fortify(departamentos) ggplot(map_df, aes(map_id = id)) + geom_map(map = map_df, color = "white", size = 0.1) + expand_limits(x = map_df$long, y = map_df$lat) + coord_map()
require("colmaps") colombia <- colmap(municipios) + theme(plot.background = element_rect(fill = "transparent", colour = "transparent"))
map_df %>% filter(id == 25) %>% ggplot + aes(x = long, y = lat) + geom_polygon() + coord_fixed()
diamonds %$% table(color, clarity) %>% as.data.frame %>% ggplot + aes(x = color, y = clarity, fill = Freq) + geom_tile()
diamonds %$% table(color, clarity) %>% as.data.frame %>% ggplot + aes(x = color, y = clarity, fill = Freq) + geom_raster()
ggplot(volcano3d, aes(x, y, z = z)) + stat_contour(binwidth = 2, size = 0.5, colour = "grey50") + stat_contour(binwidth = 10, size = 1)
iris %>% melt("Species") %>% ggplot + aes(x = value) + geom_density() + xlab("Valores") + ylab("Densidad") + facet_wrap(~variable, scale = "free")
iris %>% melt("Species") %>% ggplot + aes(x = value) + geom_density() + xlab("Valores") + ylab("Densidad") + facet_grid(Species ~ variable, scales = "free")
# Create a grid of complex numbers c.points <- outer(seq(-2.5, 1, by = 0.007), 1i*seq(-1.5, 1.5, by = 0.007),'+') z <- 0 for (k in 1:30) z <- z^2 + c.points # Iterations of fractal's formula c.points <- data.frame(reshape2::melt(c.points)) colnames(c.points) <- c("r.id", "c.id", "point") z.points <- data.frame(reshape2::melt(z)) colnames(z.points) <- c("r.id", "c.id", "z.point") mandelbrot <- merge(c.points, z.points, by = c("r.id","c.id")) # Mandelbrot Set mandelbrot <- subset(mandelbrot, is.finite(-abs(z.point))) # Plotting only finite-module numbers ggplot(mandelbrot) + aes(Re(point), Im(point), fill = exp(-abs(z.point))) + geom_tile() + theme(legend.position = "none", axis.title.x = element_blank(), axis.title.y = element_blank(), panel.background = element_rect(fill = "#132B43"), panel.grid = element_blank())