Learn R Programming

tidyplots (version 0.2.2)

rename_x_axis_labels: Rename axis or color labels

Description

Rename axis or color labels

Usage

rename_x_axis_labels(plot, new_names)

rename_y_axis_labels(plot, new_names)

rename_color_labels(plot, new_names)

Value

A tidyplot object.

Arguments

plot

A tidyplot generated with the function tidyplot().

new_names

Named character vector in the format c("old1" = "new1", "old2" = "new2").

Examples

Run this code
# Before adjustments
study |>
  tidyplot(x = treatment, y = score) |>
  add_data_points() |>
  add_mean_bar(alpha = 0.4) |>
  add_sem_errorbar()

# Rename x-axis labels
study |>
  tidyplot(x = treatment, y = score) |>
  add_data_points() |>
  add_mean_bar(alpha = 0.4) |>
  add_sem_errorbar() |>
  rename_x_axis_labels(new_names = c(
    "A" = "This",
    "B" = "is",
    "C" = "totally",
    "D" = "new"))

# Before adjustments
study |>
  tidyplot(x = score, y = treatment) |>
  add_data_points() |>
  add_mean_bar(alpha = 0.4) |>
  add_sem_errorbar()

# Rename y-axis labels
study |>
  tidyplot(x = score, y = treatment) |>
  add_data_points() |>
  add_mean_bar(alpha = 0.4) |>
  add_sem_errorbar() |>
  rename_y_axis_labels(new_names = c(
    "A" = "This",
    "B" = "is",
    "C" = "totally",
    "D" = "new"))

# Before adjustment
study |>
  tidyplot(x = group, y = score, color = dose) |>
  add_data_points() |>
  add_mean_bar(alpha = 0.4) |>
  add_sem_errorbar()

# Rename color labels
study |>
  tidyplot(x = group, y = score, color = dose) |>
  add_data_points() |>
  add_mean_bar(alpha = 0.4) |>
  add_sem_errorbar() |>
  rename_color_labels(new_names = c(
    "high" = "Sky high",
    "low" = "Deep low"))

Run the code above in your browser using DataLab