HEXPIE gallery

data(olives)
x <- olives$oleic
y <- olives$linoleic
z <- olives$Region

# the default

hexpie(x, y, z)

plot of chunk unnamed-chunk-2

# zooming in (transformation of the total number of obs in each bin)

hexpie(x, y, z, freq.trans = sqrt)

plot of chunk unnamed-chunk-3

# circular shapes

hexpie(x, y, z, freq.trans = sqrt, shape = "pie")

plot of chunk unnamed-chunk-4

# classical piecharts

hexpie(x, y, z, freq.trans = sqrt, shape = "pie", p.rule = "angles")

plot of chunk unnamed-chunk-5

# the total numbers of obs are reflected via alpha-blending, the grid is not shown and RGB colors are used

hexpie(x, y, z, freq.trans = sqrt, shape = "hex", p.rule = "radial", alpha.freq = TRUE, 
    col = "rgb", show.hex = FALSE)

plot of chunk unnamed-chunk-6

# no transformation, grid shown

hexpie(x, y, z, freq.trans = NULL, shape = "hex", p.rule = "radial", alpha.freq = TRUE, 
    col = "rgb", show.hex = TRUE)

plot of chunk unnamed-chunk-7

# diamonds data

require(ggplot2)
data(diamonds)
x2 <- diamonds$carat
y2 <- diamonds$price
z2 <- diamonds$color

# a standard plot with colors via ggplot2

qplot(x2, y2, colour = z2)

plot of chunk unnamed-chunk-9

# the hexpie version

hexpie(x2, y2, z2, n = 36)

plot of chunk unnamed-chunk-10

# zooming in via log-transformation

hexpie(x2, y2, z2, n = 36, freq.trans = function(s) log(1 + s))

plot of chunk unnamed-chunk-11

# the same, but this time the central color is the most frequent one

hexpie(x2, y2, z2, n = 36, freq.trans = function(s) log(1 + s), decr.by.rank = TRUE)

plot of chunk unnamed-chunk-12

# this way the difference is more obvious (the color palette is better suited for ordinal target variables)

hexpie(x2, y2, z2, n = 18, freq.trans = NULL, decr.by.rank = NULL, col = "div")

plot of chunk unnamed-chunk-13

hexpie(x2, y2, z2, n = 18, freq.trans = NULL, decr.by.rank = T, col = "div")

plot of chunk unnamed-chunk-14

# random samples from the data (within bins) with many bins (takes some time)

hexpie(x2, y2, z2, freq.trans = function(s) log(1 + s), random = 1, n = 120, 
    show.hex = FALSE, col.opt = list(bg = "black"))

plot of chunk unnamed-chunk-15