I am trying to create a chart, but I can't change the names of the legend items. My database is in Spanish, and I need the legend items to appear in English. Legend Items. Instead of "70 o más" I need "70+". I have already tried changing the value labels in the database and it is not working either.
This is the code for trying to change the value labels in the database
library(expss)
describe(Flow)
Flow = apply_labels(Flow,
mes = "Month",
ano= "Year",
edad="Age",
edad=c("70 or more" = "70 o Más S/E"),
This is the code for the chart:
chart<-ggplot()+
geom_line(data=Flow %>%
aes(x=date,
color=edad), stat="count") +
scale_x_date(date_minor_breaks = "1 month",
date_labels = "%Y (%b)") +
labs(color="Age")+
ggtitle("Number of Entrances, 2017-2021")
ggplotly(chart)
I'd appreciate any help!
You can use scale_colour_gradient
to set breaks
, then change the labels
.
library(tidyverse)
ggplot() +
geom_line(data=mtcars,
aes(x=cyl, y = mpg,
color=mpg)) +
scale_colour_gradient(breaks = c(15, 20, 25, 30, 40),
labels = c("1+", "2+", "3+", "4+", "5+"))
Output