0

How to rename many variables in ggplotly?

When I scroll over the interactive graphs, the names are not pleasant to look at. I want to format them to include spacing, etc.

purple_plop
  • 280
  • 1
  • 10

1 Answers1

1

You can do it with a tibble, the tidyverse's take on the data.frame.

library(tibble)
my_tbl <- tibble(`Nice variable 1` = runif(10),
                 `Special?Characters?` = runif(10),
                 `:)` = runif(10))
my_tbl

Use my_tbl as input to your ggplot object e.g. ggplot(data = my_tbl) then wrap that ggplot object with ggplotly.

Jim Kloet
  • 440
  • 3
  • 7