as_tauchart: Turn a simple (single-geom) ggplot plot into an tauchart...

Description Usage Arguments Details Value Note Examples

Description

Takes a ggplot object that has a single geom (it can be geom_line, geom_point or geom_histogram) and converts it to it's tauchart counterpart. It will do it's best to identify plot labels, mapped size & color aesthetics, and x/y limits.

Usage

1

Arguments

gg

ggplot object

Details

If there are aesthetic mappings, as_tauchart will automaticlly add a legend.

Currently supports:

Value

tauchart object

Note

More aesthetic mappings are planned

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
if (interactive()) {
library(ggplot2)
dat <- data.frame(year=seq(1790, 1970, 10),
                  uspop=as.numeric(uspop))
set.seed(5689)
data(movies, package="ggplot2")
movies <- movies[sample(nrow(movies), 1000), ]

gg <- ggplot(dat, aes(x=year, y=uspop)) + geom_line()
as_tauchart(gg)

gg <- ggplot(dat, aes(x=year, y=uspop)) + geom_point()
as_tauchart(gg)

gg <- ggplot(dplyr::count(movies, rating), aes(rating, n)) + geom_bar(stat="identity")
as_tauchart(gg)

gg <- ggplot(mtcars) + geom_point(aes(x=mpg, y=wt, color=cyl))
as_tauchart(gg)

gg <- ggplot(mtcars, aes(x=mpg, y=wt, color=am, size=wt)) + geom_point()
as_tauchart(gg)

data(economics, package="ggplot2")
gg <- ggplot(economics) + geom_line(aes(x=date, y=unemploy))
as_tauchart(gg) %>% tau_guide_x(tick_format="%Y")

gg <- ggplot(mtcars, aes(as.factor(cyl))) + geom_histogram()
as_tauchart(gg)
}

hrbrmstr/taucharts documentation built on May 17, 2019, 5:14 p.m.