Reputation: 63
I'm trying to replicate a scatterplot. the y- axis values are percentages, while the y axis values are dollar amounts. For this reason, I'd like the "%" and "$" symbols showing on every axis break. I'm not sure how to add them. This is my code for that part:
scale_x_continuous(limits = c(0, 10000), breaks = c(0, 50, 100, 200, 500, 1000, 2000, 10000)) +
scale_y_continuous(limits = c(0, 10), breaks = c(0.2, 0.5, 1, 2, 5, 10))
thankful for any insights!
Upvotes: 0
Views: 206
Reputation: 4524
With the scales - package you can add dollar or percent signs like so.
library(ggplot2)
library(scales)
x <- seq(0, 10000, 1000)
y <- seq(0,10, 1)
df <- data.frame(x,y)
ggplot(df, aes(x=x, y=y)) +
geom_point() +
geom_line() +
scale_x_continuous(labels = scales::dollar_format())
Upvotes: 1