This repository was archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 170
/
Copy pathgroupwise.Rd
56 lines (50 loc) · 1.52 KB
/
groupwise.Rd
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
% Generated by roxygen2 (4.1.0): do not edit by hand
% Please edit documentation in R/prop_group.R
\name{groupwise}
\alias{groupwise}
\alias{is.prop_group}
\title{Groupwise property}
\usage{
groupwise(prop, offset = NULL, mult = NULL)
is.prop_group(x)
}
\arguments{
\item{prop}{Name of the group property. Typically "height" or "width".}
\item{offset,mult}{Additive and multiplicate offsets.}
\item{x}{object to test for group-ness}
}
\description{
\code{groupwise()} is used to refer to properties of the plot or
subvisualisation, typically the height or the width.
}
\examples{
# In the following example, we draw a rectangle running vertically
# across the plot by referring to its total height
ggvis(faithful) \%>\%
layer_histograms(~eruptions) \%>\%
emit_rects(props(
x = ~mean(eruptions), width := 40,
y := 0, y2 := groupwise("height"),
fill := "red"
))
# The mult factor is useful to draw elements at fixed fractions
# of the plot:
ggvis(mtcars, ~mpg) \%>\%
layer_histograms() \%>\%
layer_axial_lines(y := groupwise("height", mult = 0.5),
stroke := "red", strokeWidth := 4)
# Combining mult and offset makes it is easy to place elements where
# you want them
ggvis(faithful) \%>\%
layer_histograms(~eruptions) \%>\%
emit_rects(props(
x := 30, x2 := groupwise("width", -15, 0.5),
y := 30, y2 := groupwise("height", -30),
fill := "red"
)) \%>\%
emit_rects(props(
x := groupwise("width", 15, 0.5), x2 := groupwise("width", -30),
y := groupwise("height", -30), y2 := 30,
fill := "blue"
))
}