dumbbell_chart: Dumbbell Chart

Description Usage Arguments Value Author(s) Examples

View source: R/dumbbell_chart.R

Description

Use this function to create a dumbbell chart to compare two numeric variables along a factor variable

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
dumbbell_chart(
  plot_data,
  x1_name,
  x2_name,
  y_name,
  line_color = "#bdbdbd",
  x1_color = "#5884d6",
  x2_color = "#bbe64e",
  plot_height = NULL,
  plot_width = NULL,
  show_legend = TRUE,
  show_x_axis_grid = FALSE,
  show_y_axis_grid = FALSE,
  marker_size = marker_default_size,
  plot_title = NULL,
  x_axis_title = NULL,
  y_axis_title = NULL
)

Arguments

plot_data

The data which will be used for the plot

x1_name

The column name of one of the the variable in the x-axis, It has to be a numeric variable

x2_name

The column name of the other variable in the x-axis, It has to be a numeric variable

y_name

The column name of the the variable in the y-axis, It has to be a factor variable

line_color

string. This is the color of the line between the two points, defaults to a grey shade

x1_color

string. This is the color of the point made by x1_name variable, defaults to a bluish color

x2_color

string. This is the color of the point made by x2_name variable, defaults to a version of lime green

plot_height

num. The height of the plot, If not provided the plot will take the whole area available in the UI

plot_width

num. The height of the plot, If not provided the plot will take the whole area available in the UI

show_legend

boolean. This will let you display or hide the grids in the x-axis, default shown

show_x_axis_grid

boolean. This will let you display or hide the grids in the x-axis, default hidden

show_y_axis_grid

boolean. This will let you display or hide the grids in the y-axis, default hidden

marker_size

num. This is the size of the markers in the scatter plot, defaults to marker_default_size from constants.R

plot_title

string. This is the title of the plot, defauts to NULL

x_axis_title

string. This is the x-axis title of the plot, defaults to NULL

y_axis_title

string. This is the y-axis title of the plot, defaults to NULL

Value

Returns a plotly plot object which can be rendered as HTML

Author(s)

Vedha Viyash

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## This will load two data.frames `marks_data` and `gender_school_earnings`
data("tidychartsdata")

## You can plot a dumbbell chart using by just specifying data, x1_name, x2_name and y_name.
dumbbell_chart(gender_school_earnings, Men, Women, School)

## If you want to specify particular color, you can specify them to their respective arguments
dumbbell_chart(
  gender_school_earnings, Men, Women, School,
  line_color = "#6ba1e8", x1_color = "#4c7ced", x2_color = "#a7d1eb"
)

vedhav/tidycharts documentation built on Nov. 15, 2020, 3:26 p.m.