Skip to content
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
Closed

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

emillykkejensen opened this issue Oct 5, 2016 · 5 comments

Comments

@emillykkejensen
Copy link

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
Copy link
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
Copy link
Author

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
Copy link
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 as completed in 4a151a4 Oct 5, 2016
@hadley
Copy link
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
Copy link
Author

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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants