flip_ggplot_build: Ggplot_build for flipped plots

Description Usage Arguments Details Examples

View source: R/plot_panel.R

Description

flip_ggplot_build is a supplementary function for ggplot_build. Changes ggplot_build output in order to make it compatible with the plot when coordinates are flipped.

Usage

1
flip_ggplot_build(ggplot_build_data)

Arguments

ggplot_build_data

output of ggplot_build

Details

data from the output of ggplot_build has names of columns compatible with the mapping. In case when coordinates are flipped, it is not consistent with the displayed plot. flip_ggplot_build changes the names so that coordinates from the output of ggplot_build are compatible with the plot and returns it. In case when coordinates are not flipped flip_ggplot_build returns ggplot_build_data.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 

# returns plot info without any change because coordinates are not flipped
p <- ggplot(Orange, aes(x = age, y = circumference, col = Tree)) +
geom_point() +
geom_line()
plot_info <- ggplot_build(p)
flip_ggplot_build(plot_info) # it is the same as plot_info

# returns plot info with data modified for flipped coordinates
p <- ggplot(Orange, aes(x = age, y = circumference, col = Tree)) +
geom_point() +
geom_line() +
coord_flip()
plot_info <- ggplot_build(p)
flip_ggplot_build(plot_info)

## End(Not run)

BioGenies/shinydetails documentation built on March 1, 2021, 11:12 p.m.