Custom ggplot2 axis and label formatting

You can set the prefix in dollar_format for euros instead of dollars:

scale_y_continuous(labels=dollar_format(prefix="€")) +

That takes care of the scientific notation issue.

To get everything in thousands, you could just divide by 1000 when you create the summary. To reduce clutter, you could leave out the euro symbol in the bar labels, but I've kept the symbol in the example below:

df.summary = df %>% group_by(Brand, Category) %>% 
  summarise(EUR = sum(EUR)/1000) %>%   # Within each Brand, sum all values in each Category
  mutate( pos = (cumsum(EUR)-0.5*EUR))

ggplot(df.summary, aes(x=reorder(Brand,EUR,function(x)+sum(x)), y=EUR, fill=Category)) +
  geom_bar(stat='identity',  width = .7, colour="black", lwd=0.1) +
  geom_text(aes(label=ifelse(EUR>100,paste0("€", round(EUR,0)),""),
                y=pos), colour="white") +
  scale_y_continuous(labels=dollar_format(prefix="€")) +
  coord_flip()+
  labs(y="Thousands of €", x="")

enter image description here


This also works

scale_y_continuous(labels = function(x) paste0(x, "€"))

You can put any symbol you want in lieu of the €