Skip to content

Commit

Permalink
Tweak icons
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed May 9, 2018
1 parent f19c3cb commit 0648739
Show file tree
Hide file tree
Showing 68 changed files with 119 additions and 87 deletions.
Binary file modified icons/coord_cartesian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/coord_fixed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/coord_flip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/coord_map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/coord_polar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/coord_transform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/facet_grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file renamed icons/geom_hline.png → icons/facet_wrap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/geom_abline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/geom_area.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/geom_bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file renamed icons/geom_errorbar.png → icons/geom_bin2d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file renamed icons/geom_vline.png → icons/geom_blank.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/geom_boxplot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/geom_contour.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/geom_count.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/geom_crossbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/geom_density.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/geom_dotplot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/geom_freqpoly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file renamed icons/geom_errorbarh.png → icons/geom_hex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/geom_histogram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/geom_jitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/geom_line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed icons/geom_linerange.png
Binary file not shown.
Binary file added icons/geom_map.png
Binary file modified icons/geom_path.png
Binary file modified icons/geom_point.png
Binary file modified icons/geom_pointrange.png
Binary file modified icons/geom_polygon.png
Binary file modified icons/geom_quantile.png
Binary file modified icons/geom_raster.png
Binary file modified icons/geom_rect.png
Binary file modified icons/geom_ribbon.png
Binary file renamed icons/facet_null.png → icons/geom_rug.png
Binary file modified icons/geom_segment.png
Binary file added icons/geom_sf.png
Binary file modified icons/geom_smooth.png
Binary file added icons/geom_spoke.png
Binary file modified icons/geom_step.png
Binary file modified icons/geom_text.png
Binary file modified icons/geom_tile.png
Binary file modified icons/geom_violin.png
206 changes: 119 additions & 87 deletions icons/icons.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set.seed(1014)

write_icon <- function(name, code) {
path <- paste0("icons/", name, ".png")
png(path, width = 80, height = 80, pointsize = 18)
png(path, width = 60, height = 60, pointsize = 18)
on.exit(dev.off())

grid.draw(code)
Expand Down Expand Up @@ -62,6 +62,9 @@ write_icon("coord_map", {
linesGrob(nz$x, nz$y, default.units = "npc")
})

file.copy("icons/coord_map.png", "icons/geom_map.png")
file.copy("icons/coord_map.png", "icons/geom_sf.png")

write_icon("coord_polar", {
circleGrob(r = c(0.1, 0.25, 0.45), gp = gpar(fill = NA))
})
Expand Down Expand Up @@ -100,27 +103,18 @@ write_icon("facet_grid", {
))
})

write_icon("facet_null", {
write_icon("facet_wrap", {
gTree(children = gList(
rectGrob(
0,
1,
width = 0.95,
c(0.49, 1),
width = 1,
height = 0.05,
hjust = 0,
vjust = 1,
gp = gpar(fill = "grey60", col = NA)
),
rectGrob(
0.95,
0.95,
width = 0.05,
height = 0.95,
hjust = 0,
vjust = 1,
gp = gpar(fill = "grey60", col = NA)
),
segmentsGrob(c(0, 0.475), c(0.475, 0), c(1, 0.475), c(0.475, 1))
segmentsGrob(c(0, 0.5), c(0.5, 0), c(1, 0.5), c(0.5, 1))
))
})

Expand All @@ -139,6 +133,34 @@ write_icon("geom_bar", {
)
})

write_icon("geom_bin2d", {
n <- 5
x <- seq(0, 1, length = n + 1)[-(n + 1)]
out <- expand.grid(x = x, y = x)
fill <- sqrt((out$x - 0.5) ^ 2 + (out$y - 0.5) ^ 2)

pal <- scales::seq_gradient_pal("#56B1F7", "#132B43")
rectGrob(
out$x + 1/n/2,
out$y + 1/n/2,
width = 1/n,
height = 1/n,
gp = gpar(col = "grey20", fill = pal(scales::rescale(fill)))
)
})

write_icon("geom_blank", {
rectGrob(0.5, 0.5,
height = 1,
width = 1,
gp = gpar(fill = "white", col = "black", lwd = 3)
)
})

write_icon("geom_count", {
textGrob(expression(Sigma), gp = gpar(cex = 4))
})

write_icon("geom_histogram", {
y <- c(0.2, 0.3, 0.5, 0.6, 0.2, 0.8, 0.5, 0.3)
rectGrob(
Expand Down Expand Up @@ -167,14 +189,20 @@ write_icon("geom_boxplot", {

write_icon("geom_crossbar", {
gTree(children = gList(
# crossbar
rectGrob(
c(0.3, 0.7),
c(0.6, 0.8),
0.3,
0.6,
width = 0.3,
height = c(0.4, 0.4),
vjust = 1
),
segmentsGrob(c(0.15, 0.55), c(0.5, 0.6), c(0.45, 0.85), c(0.5, 0.6))
segmentsGrob(c(0.15), c(0.5), c(0.45), c(0.5)),

# error bar
segmentsGrob(0.70, 0.5, 0.70, 0.90),
segmentsGrob(0.55, 0.5, 0.85, 0.50),
segmentsGrob(0.55, 0.9, 0.85, 0.90)
))
})

Expand All @@ -191,35 +219,11 @@ write_icon("geom_dotplot", {
)
})

write_icon("geom_errorbar", {
gTree(children = gList(
segmentsGrob(c(0.3, 0.7), c(0.3, 0.5), c(0.3, 0.7), c(0.7, 0.9)),
segmentsGrob(c(0.15, 0.55), c(0.3, 0.5), c(0.45, 0.85), c(0.3, 0.5)),
segmentsGrob(c(0.15, 0.55), c(0.7, 0.9), c(0.45, 0.85), c(0.7, 0.9))
))
})

write_icon("geom_errorbarh", {
gTree(children = gList(
segmentsGrob(c(0.5, 0.3), c(0.70, 0.30), c(0.9, 0.7), c(0.70, 0.30)),
segmentsGrob(c(0.5, 0.3), c(0.55, 0.15), c(0.5, 0.3), c(0.85, 0.45)),
segmentsGrob(c(0.9, 0.7), c(0.55, 0.15), c(0.9, 0.7), c(0.85, 0.45))
))
})

write_icon("geom_freqpoly", {
y <- c(0.2, 0.3, 0.5, 0.6, 0.2, 0.8, 0.5, 0.3)
linesGrob(seq(0.1, 0.9, by = 0.1), y, gp = gpar(col = "grey20"))
})

write_icon("geom_hline", {
linesGrob(c(0, 1), c(0.5, 0.5))
})

write_icon("geom_linerange", {
segmentsGrob(c(0.3, 0.7), c(0.1, 0.2), c(0.3, 0.7), c(0.7, 0.95))
})

write_icon("geom_path", {
linesGrob(c(0.2, 0.4, 0.8, 0.6, 0.5), c(0.2, 0.7, 0.4, 0.1, 0.5))
})
Expand All @@ -234,16 +238,25 @@ write_icon("geom_contour", {
)))
})

write_icon("geom_hex", {
theta <- seq(0, 2 * pi, length = 7)[-1]
polygonGrob(
0.5 + 0.4 * sin(theta),
0.5 + 0.4 * cos(theta),
gp = gpar(fill = "grey50", col = NA)
)
})

write_icon("geom_line", {
pos <- seq(0, 1, length.out = 5)
linesGrob(pos, c(0.2, 0.7, 0.4, 0.8, 0.3))
linesGrob(pos, c(0.2, 0.7, 0.4, 0.8, 0.3), gp = gpar(lwd = 3))
})

write_icon("geom_step", {
n <- 15
xs <- rep(0:n, each = 2)[-2 * (n + 1)] / 15
ys <- c(0, rep(1:n, each = 2)) / 15
linesGrob(xs, ys, gp = gpar(col = "grey20"))
n <- 10
xs <- rep(0:n, each = 2)[-2 * (n + 1)] / n
ys <- c(0, rep(1:n, each = 2)) / n
linesGrob(xs, ys, gp = gpar(col = "grey20", lwd = 3))
})

write_icon("geom_point", {
Expand All @@ -258,10 +271,9 @@ write_icon("geom_point", {
})

write_icon("geom_jitter", {
pos <- seq(0.1, 0.9, length.out = 6)
pointsGrob(
x = pos,
y = jitter(pos, 3),
x = c(0.25, 0.22, 0.34, 0.70, 0.77, 0.80),
y = c(0.15, 0.24, 0.28, 0.65, 0.90, 0.75),
pch = 19,
gp = gpar(col = "black", cex = 0.5),
default.units = "npc"
Expand Down Expand Up @@ -330,6 +342,17 @@ write_icon("geom_ribbon", {
)
})

write_icon("geom_spoke", {
theta <- seq(0, 2 * pi, length = 10)[-1]
r <- seq(0.1, 0.45, length = length(theta))
segmentsGrob(
0.5, 0.5,
0.5 + sin(theta) * r,
0.5 + cos(theta) * r,
gp = gpar(col = "grey20")
)
})

write_icon("geom_area", {
polygonGrob(c(0, 0, 0.3, 0.5, 0.8, 1, 1),
c(0, 1, 0.5, 0.6, 0.3, 0.8, 0),
Expand All @@ -342,6 +365,15 @@ write_icon("geom_density", {
linesGrob(x, 0.05 + y / max(y) * 0.9, default.units = "npc")
})


write_icon("geom_rug", {
x <- seq(0.15, 0.95, length = 8)
gList(
segmentsGrob(x, 0, x, 0 + 0.1, gp = gpar(lwd = 2)),
segmentsGrob(0, x, 0 + 0.1, x, gp = gpar(lwd = 2))
)
})

write_icon("geom_segment", {
segmentsGrob(c(0.1, 0.3, 0.5, 0.7),
c(0.3, 0.5, 0.1, 0.9),
Expand Down Expand Up @@ -391,10 +423,6 @@ write_icon("geom_violin", {
))
})

write_icon("geom_vline", {
linesGrob(c(0.5, 0.5), c(0, 1))
})

# Position adjustments --------------------------------------------------------

write_icon("position_dodge", {
Expand Down Expand Up @@ -451,7 +479,8 @@ write_icon("position_stack", {
write_icon("scale_alpha", {
x <- c(0.1, 0.3, 0.5, 0.7, 0.9)
rectGrob(x,
width = 0.25,
width = 0.3,
height = x,
gp = gpar(fill = scales::alpha("black", x), col = NA))
})

Expand All @@ -463,28 +492,43 @@ write_icon("scale_colour_brewer", {
)
})

write_icon("scale_colour_gradient", {
g <- scale_fill_gradient()
g$train(1:5)
write_icon("scale_colour_continuous", {
g1 <- scale_fill_gradient()
g1$train(1:5)

g2 <- scale_fill_viridis_c()
g2$train(1:5)

x <- c(0.1, 0.3, 0.5, 0.7, 0.9)
rectGrob(
c(x, x),
rep(c(0.25, 0.75), each = 5),
width = 0.21,
height = 0.5,
gp = gpar(fill = c(g1$map(1:5), g2$map(5:1)), col = NA)
)
})

write_icon("scale_colour_viridis_d", {
rectGrob(
c(0.1, 0.3, 0.5, 0.7, 0.9),
width = 0.21,
gp = gpar(fill = g$map(1:5), col = NA)
)
})

write_icon("scale_colour_gradient2", {
g <- scale_fill_gradient2()
g$train(1:5 - 3)
write_icon("scale_colour_gradient", {
g <- scale_fill_gradient()
g$train(1:5)
rectGrob(
c(0.1, 0.3, 0.5, 0.7, 0.9),
width = 0.21,
gp = gpar(fill = g$map(1:5 - 3), col = NA)
gp = gpar(fill = g$map(1:5), col = NA)
)
})

write_icon("scale_colour_gradientn", {
g <- scale_fill_gradientn(colours = rainbow(7))
write_icon("scale_colour_viridis", {
g <- scale_fill_viridis_c()
g$train(1:5)
rectGrob(
c(0.1, 0.3, 0.5, 0.7, 0.9),
Expand All @@ -493,10 +537,11 @@ write_icon("scale_colour_gradientn", {
)
})


write_icon("scale_colour_grey", {
rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9),
width = 0.21,
gp = gpar(fill = gray(seq(0, 1, length.out = 5)), col = NA))
gp = gpar(fill = gray(seq(0, 0.9, length.out = 5)), col = NA))
})

write_icon("scale_colour_hue", {
Expand All @@ -507,15 +552,11 @@ write_icon("scale_colour_hue", {
), col = NA))
})

write_icon("scale_colour_identity", {
textGrob("f(x) = x", gp = gpar(cex = 1.2))
})

write_icon("scale_linetype", {
gTree(children = gList(
segmentsGrob(0, 0.25, 1, 0.25, gp = gpar(lty = 1)),
segmentsGrob(0, 0.50, 1, 0.50, gp = gpar(lty = 2)),
segmentsGrob(0, 0.75, 1, 0.75, gp = gpar(lty = 3))
segmentsGrob(0, 0.25, 1, 0.25, gp = gpar(lty = 1, lwd = 3)),
segmentsGrob(0, 0.50, 1, 0.50, gp = gpar(lty = 2, lwd = 3)),
segmentsGrob(0, 0.75, 1, 0.75, gp = gpar(lty = 3, lwd = 3))
))
})

Expand All @@ -524,12 +565,13 @@ write_icon("scale_colour_manual", {
})

write_icon("scale_shape", {
gp <- gpar(lwd = 3)
gTree(children = gList(
circleGrob(0.7, 0.7, r = 0.1),
segmentsGrob(0.2, 0.3, 0.4, 0.3),
segmentsGrob(0.3, 0.2, 0.3, 0.4),
polygonGrob(c(0.2, 0.2, 0.4, 0.4), c(0.8, 0.6, 0.6, 0.8)),
polygonGrob(c(0.6, 0.7, 0.8), c(0.2, 0.4, 0.2))
circleGrob(0.7, 0.7, r = 0.1, gp = gp),
segmentsGrob(0.2, 0.3, 0.4, 0.3, gp = gp),
segmentsGrob(0.3, 0.2, 0.3, 0.4, gp = gp),
polygonGrob(c(0.2, 0.2, 0.4, 0.4), c(0.8, 0.6, 0.6, 0.8), gp = gp),
polygonGrob(c(0.6, 0.7, 0.8), c(0.2, 0.4, 0.2), gp = gp)
))
})

Expand All @@ -542,15 +584,5 @@ write_icon("scale_size", {
})

write_icon("scale_x_date", {
textGrob("14/10/1979", gp = gpar(cex = 1))
})

# Statistics -------------------------------------------------------------------

write_icon("stat_identity", {
textGrob('f(x) = x', gp = gpar(cex = 1.2))
})

write_icon("stat_sum", {
textGrob(expression(Sigma), gp = gpar(cex = 4))
textGrob("14/10/1979", gp = gpar(cex = 0.9), rot = 45)
})
Binary file modified icons/position_dodge.png
Binary file modified icons/position_fill.png
Binary file modified icons/position_identity.png
Binary file modified icons/position_jitter.png
Binary file modified icons/position_stack.png
Binary file modified icons/scale_alpha.png
Binary file modified icons/scale_colour_brewer.png
Binary file modified icons/scale_colour_gradient.png
Binary file modified icons/scale_colour_grey.png
Binary file modified icons/scale_colour_hue.png
Binary file removed icons/scale_colour_identity.png
Diff not rendered.
Binary file modified icons/scale_colour_manual.png
Binary file added icons/scale_colour_viridis_d.png
Binary file removed icons/scale_identity.png
Diff not rendered.
Binary file modified icons/scale_linetype.png
Binary file removed icons/scale_manual.png
Diff not rendered.
Binary file modified icons/scale_shape.png
Binary file modified icons/scale_size.png
Binary file modified icons/scale_x_date.png
Binary file removed icons/scale_x_datetime.png
Diff not rendered.
Binary file removed icons/stat_identity.png
Diff not rendered.
Binary file removed icons/stat_sum.png
Diff not rendered.

0 comments on commit 0648739

Please sign in to comment.