scale_y_continuous(labels = scales::percent) - Question

Hi there,

I need some help. I am trying to insert the symbol "%" in the Y-axis of my graph. The numbers are already in % but without such symbols. When I try:

scale_y_continuous(labels = scales::percent)

I get for my 100 --> 10000% instead of 100%

Can you please tell me how I can do that?


use the same code to use scales percentage with symbols but have your values be divided by a 100 so that they are the decimal representation of the percentages you need.

Thanks. I have another issue with the geom_vline().
I am trying to draw a vertical line on my X-axis but it does not take that. Can you please help me with this as well?

Here is the code:

map(2016:2020, ~ make_returns(Data_m2, .x)) %>%'rbind', .) %>%
ggplot(aes(x = year_month, y = mean, colour = tercile)) +
scale_color_manual(name = "tercile", values = c("red", "blue"), labels = c("high CSR portfolio", "low CSR portfolio")) +
scale_linetype_manual(name = "tercile", values = c("dashed", "solid"), labels = c("high CSR portfolio", "low CSR portfolio")) +
labs(x = "year", y = "market returns (%)", title = "Portfolios' returns using Sustainalytics ESG total score", font.main=4, font.lab=4) +
scale_x_date(breaks = as.Date(c("2016-01-31", "2017-01-31", "2018-01-31","2019-01-31", "2020-01-31", "2020-12-31")), date_labels = "%Y (%b)") +
geom_vline(xintercept = 2017-01-31, linetype = 2)

Divide the y variable by 100.

aes(x = your_x_var, y = your_y_var/100)

Then you can use scales::percent or scales::percent_format.

1 Like

Thanks, can you please help me with the other issue as well?

Please make a new question topic if it's not related to this topic. And don't forget to mark the answer as the solution that worked for you.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.