New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode donen't work on axis text but on geom_text? #1827

Closed
emillykkejensen opened this Issue Oct 5, 2016 · 5 comments

Comments

Projects
None yet
2 participants
@emillykkejensen

emillykkejensen commented Oct 5, 2016

I can't seem to get the axis text showing unicode, but when i try it in geom_text it shows up just fine.

Is there a way to do this or...?

ggdata <- data.frame(text = c("text 1", "text <U+2665>", "text ♥"), value = c(1, 3, 5), stringsAsFactors = FALSE)

ggplot(data = ggdata, aes( x = text, y = value, label = text)) + geom_bar(stat="identity") + geom_text(nudge_y = 1)

rplot

@hadley

This comment has been minimized.

Member

hadley commented Oct 5, 2016

It works for me, but you're probably on windows. Can you please confirm the simpler reprex below still illustrates the problem for you?

df <- tibble::tibble(x = c("a", ""))

ggplot(df, aes(x, x)) + 
  geom_text(aes(label = x))
@emillykkejensen

This comment has been minimized.

emillykkejensen commented Oct 5, 2016

The problem is stil there. And yes, I'm one a Windows - just tried to run your code on a linux server I have, and there it worked fine.

rplot

@hadley

This comment has been minimized.

Member

hadley commented Oct 5, 2016

The root cause seems to be a buglet in R. On windows, I see:

x <- c("a", "")
format(x)
#> [1] "a       " "<U+2665>"

😞

@hadley hadley closed this in 4a151a4 Oct 5, 2016

@hadley

This comment has been minimized.

Member

hadley commented Oct 5, 2016

Ok, pretty sure I fixed it, just by avoiding the use of format() (which I'm not sure why was necessary in most cases anyway). Please let me know if this doesn't fix the problem.

@emillykkejensen

This comment has been minimized.

emillykkejensen commented Oct 5, 2016

Works! Thanks :-)

@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.