-
-
Notifications
You must be signed in to change notification settings - Fork 978
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 symbols in ggplot fail to render, but only in markdown #2256
Comments
Thanks for confirming. FYI: I get the same problem with other devices like |
That's weird. When the device is I can't see your Unicode symbols on macOS (not even in plain text). They are probably only available on Windows. @cderv If you want to debug it, you may see if the recorded plot can be correctly replayed in the second ragg::agg_png("f1.png")
dev.control(displaylist = 'enable')
# draw the plot, then
x = recordPlot()
dev.off()
ragg::agg_png("f2.png")
x
dev.off() |
Thanks for the help @yihui Yes doing this works as expected - both files contains the character ragg::agg_png("f1.png")
dev.control(displaylist = 'enable')
library(ggplot2)
ggplot(mtcars) +
aes(x=hp, y=mpg) +
geom_point() +
labs(y = "Arrows 🠜 🠞")
x = recordPlot()
dev.off()
ragg::agg_png("f2.png")
x
dev.off() I can't reproduce the issue on Linux either so this must be specific character from Windows. I am surprise that something is happening in the process. Maybe related to encoding as Windows is non UTF-8 native yet. |
I tried to look more closer inside the element. During the knit process, the recorded plot is in str(res[[3]], 1)
List of 3
$ :Dotted pair list of 3
$ : raw [1:35992] 00 00 00 00 ...
..- attr(*, "pkgName")= chr "graphics"
$ :List of 2
..- attr(*, "pkgName")= chr "grid"
- attr(*, "engineVersion")= int 14
- attr(*, "pid")= int 42956
- attr(*, "Rversion")=Classes 'R_system_version', 'package_version', 'numeric_version' hidden list of 1
- attr(*, "load")= chr(0)
- attr(*, "attach")= chr(0)
- attr(*, "class")= chr "recordedplot" and within this object, there is the label which is not correctly encoded .. .. .. .. .. ..$ :List of 7
.. .. .. .. .. .. ..$ widths :List of 3
.. .. .. .. .. .. .. ..$ :Classes 'unit', 'unit_v2' hidden list of 1
.. .. .. .. .. .. .. .. ..$ :List of 3
.. .. .. .. .. .. .. .. .. ..$ : num 0
.. .. .. .. .. .. .. .. .. ..$ : NULL
.. .. .. .. .. .. .. .. .. ..$ : int 8
.. .. .. .. .. .. .. ..$ :Classes 'unit', 'unit_v2' hidden list of 1
.. .. .. .. .. .. .. .. ..$ :List of 3
.. .. .. .. .. .. .. .. .. ..$ : num 1
.. .. .. .. .. .. .. .. .. ..$ :List of 2
.. .. .. .. .. .. .. .. .. .. ..$ :Classes 'unit', 'unit_v2' hidden list of 1
.. .. .. .. .. .. .. .. .. .. .. ..$ :List of 3
.. .. .. .. .. .. .. .. .. .. .. .. ..$ : num 1
.. .. .. .. .. .. .. .. .. .. .. .. ..$ :List of 11
.. .. .. .. .. .. .. .. .. .. .. .. .. ..$ label : chr "Arrows <U+0001F81C> <U+0001F81E>" @yihui could it be again related to other encoding issue in evaluate: r-lib/evaluate#66 and r-lib/evaluate#59, linked to yihui/knitr#1944 ? |
I believe this could indeed be the issue. I did the test with the current R-devel UCRT (https://developer.r-project.org/WindowsBuilds/winutf8/ucrt3/howto.html) and rendering the document works properly. We were waiting for that regarding the issue in the evaluate package and this is coming soon: the support for UTF-8 by default on Windows in R will be for next version R 4.2 and this is coming in the regular R-devel version Next monday So I believe this is an issue that will resolve itself at next R version. |
Yes, I'm excited to learn that the UTF-8 support is finally going into R 4.2! I've been waiting for this for years. |
In an RMD file knitted to HTML, unicode symbols in ggplot show up incorrectly.
Here's an example:
The axis label is mangled:
But if I copy the code for that plot into an R file, it works as expected:
The text was updated successfully, but these errors were encountered: