set_scales: Set palettes and variables to map data to aesthetics

Description Usage Arguments Details Value Author(s) Examples

Description

These functions provide ways to modify the palettes, variables to create aesthetics and their titles in a data object created by qdata. Currently supported aesthetics are about color, border and size of graphical elements.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
color_pal(data) <- value

color_var(data) <- value

color_title(data) <- value

border_pal(data) <- value

border_var(data) <- value

border_title(data) <- value

size_pal(data) <- value

size_var(data) <- value

size_title(data) <- value

Arguments

data

the data object

value

the palette (as a function mapping a data variable to graphical properties), the variable name (as a character scalar), or the title (as a character scalar)

Details

All these information is called “scales” (in the ggplot2 term) and stored in attr(data, 'Scales'). Usually palette functions are from the scales package.

Value

The corresponding scale information in data is set to value.

Author(s)

Yihui Xie <http://yihui.name>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
library(cranvas)
library(scales)
qtennis <- qdata(tennis, color = aces)

qscatter(server.pts, first.serves, data = qtennis)
qparallel(10:14, data = qtennis)  # variables including Aces
qscatter(server.pts, aces, data = qtennis)


## now notice the color changes in the plot
color_pal(qtennis) <- div_gradient_pal()  # change to diverging gradient palette

color_var(qtennis) <- "first.serves"  # change color variable from Aces to First.Serves

color_title(qtennis) <- "First Serves"  # change title; to be used in legend

cranvas_off()

ggobi/cranvas documentation built on May 17, 2019, 3:10 a.m.