European/french thousand separator in ggplot

2019-06-19 18:57发布

问题:

I'm trying to format the y axis in a ggplot graph with a space (and not a comma) as thousand separator ; something like 10 000 and not 10,000. I can't found it in the scale_y_continuous help.

Thanks for any hint.

回答1:

As @David and @joran just said.

First, define the label formatter:

space <- function(x, ...) { 
  format(x, ..., big.mark = " ", scientific = FALSE, trim = TRUE)
}

and then use it with scale_y_continous:

plot + scale_y_continuous(labels = space)


回答2:

I'm just taking a stab in the dark, but scale_y_continuous(labels = space) might do the trick.



标签: r ggplot2