dumbbell_chart: Dumbbell Chart

Description Usage Arguments Value Author(s) See Also Examples

View source: R/dumbbell_chart.R

Description

Easily create a dumbbell chart

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
dumbbell_chart(
  data,
  x,
  y1,
  y2,
  line_size = 1.5,
  line_color = "lightgray",
  point_size = 4,
  point_colors = c("#1F77B4", "#FF7F0E"),
  sort = TRUE,
  horizontal = TRUE,
  top_n = NULL,
  legend = TRUE,
  legend_labels = waiver(),
  limit = NULL
)

Arguments

data

Dataset to use for the dumbbell chart

x

character or factor column of data

y1

numeric column of data representing the dumbbell end

y2

numeric column of data representing the dumbbell start

line_size

numeric. Line width

line_color

character. Line color

point_size

numeric. Point size

point_colors

numeric. Point color

sort

logical. Should the data be sorted by y2 before plotting?

horizontal

logical. Should the plot be displayed horizontally?

top_n

integer. If a value for top_n is provided only the first top_n records will be displayed

legend

logical. Should a legend be displayed?

legend_labels

character. Custom labels to be displayed in the legend

limit

Deprecated. use top_n instead.

Value

An object of class ggplot

Author(s)

Thomas Neitmann

See Also

To learn how to further customize this plot have a look at the 'customize' vignette: vignette("customize", package = "ggcharts")

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
data(popeurope)

dumbbell_chart(popeurope, country, pop1952, pop2007)

# Display only the top 10 countries in terms of population in 2007
dumbbell_chart(popeurope, country, pop1952, pop2007, top_n = 10)

# Change line and point color
dumbbell_chart(popeurope, country, pop1952, pop2007, top_n = 10,
               line_color = "lightgray", point_color = c("lightgray", "black"))

# Add custom legend labels
dumbbell_chart(popeurope, country, pop1952, pop2007, top_n = 10,
               legend_labels = c("1952", "2007"))

# Increase line width and point size
dumbbell_chart(popeurope, country, pop1952, pop2007, top_n = 10,
               line_size = 2, point_size = 5)

thomas-neitmann/ggcharts documentation built on Oct. 8, 2021, 1:17 a.m.