bubble_plot: Create 'bubble' plot

View source: R/bubble_plot.R

bubble_plotR Documentation

Create 'bubble' plot

Description

bubble_plot produces a ggplot bubble plot from a data.frame

Usage

bubble_plot(
  plot_df,
  x = "x",
  y = "y",
  size = "size",
  fill = "fill",
  x_labels = NULL,
  y_labels = NULL,
  ...
)

Arguments

plot_df

data.frame data to plot

x

character Name of the variable to plot on the x-axis

y

character Name of the variable to plot on the y-axis

size

character Name of the variable to use for the size of the points

fill

character Name of the variable to use for the fill colour

x_labels

character Optional labels to use instead of levels of x-axis variable

y_labels

character Optional labels to use instead of levels of y-axis variable

...

Other arguments passed on to geom_point

Details

This function takes a data.frame and creates a bubble plot. An x-y scatterplot where an attribute is represented by the size of the points and optionally an another attribute is mapped to the colour.

Value

plot - ggplot2 object

Examples


set.seed(20962)
test_data_cat <- data.frame(x = factor(rep(LETTERS[1:10], 10)),
  y = factor(rep(1:10, each = 10), levels = 10:1),
  size = sample(20:100, 100, replace = TRUE),
  fill = runif(100))

cat_bubble_plot <- bubble_plot(test_data_cat)

test_data_num <- test_data_cat
test_data_num$x <- sample(1:50, 20)
test_data_num$y <- sample(1:50, 20)

num_bubble_plot <- bubble_plot(test_data_num)


richysix/biovisr documentation built on Feb. 3, 2024, 4:36 a.m.