comma as a separator for decimal places

1,992 views
Skip to first unread message

Arko

unread,
Oct 31, 2010, 10:49:55 AM10/31/10
to ggplot2
Hi all!

I am plot some graphics with ggplot2 and I need axis have commas as
separator for decimal places instead of dots (i.e. 0.85 >>>> 0,85).
How can I do that?

Thanx.

Arko

unread,
Nov 1, 2010, 7:52:51 AM11/1/10
to ggplot2
I am sorry I did not provide you the data and code used in my question
to "increase value considerably" and "force potencial helpers to
either respond abstractly and/or without testing" or "make up a
reproducible example of their own".
So, here we go:

library(ggplot2)
m <- ggplot(movies, aes(x=rating))
m + geom_density()

I would like to change 0.00 0.05 0.10 and so on, to 0,00 0,05 0,10 and
so...

Thanx in advance.

Ista Zahn

unread,
Nov 1, 2010, 10:59:18 AM11/1/10
to Arko, ggplot2
HI Arko,
Thanks for the reproducible example. I would accomplish this simply by
setting the breaks and labels manually, like this:

m + geom_density() +
scale_y_continuous(breaks=seq(0,.25, by=.05), labels=gsub("\\.", ",",
seq(0,.25, by=.05)))

Best,
Ista

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>

--
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

baptiste auguie

unread,
Nov 1, 2010, 11:04:47 AM11/1/10
to Arko, ggplot2
Hi,

Try this,

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

last_plot() + scale_y_continuous(formatter="comma2")

Arko

unread,
Nov 1, 2010, 1:17:01 PM11/1/10
to ggplot2
Wow!
That is exactly what I need! Thank you very much!

Reply all
Reply to author
Forward
0 new messages