Juan Carlos Suárez
2018-09-22 21:00:00 UTC
Hi there
I have a bunch of R scripts doing plots with ggplot2 (nice package!). Since
I plot plenty of greek variables, I decided to use latex2exp package to
display greek character in ggplot2 plots.
This worked for me without any problem, but now it does not longer work. I
have been investigating if the problem may come from updates in the
packages, but
I am not able to find where is the problem.
The point is that I use greek chacarcters in both the x and y labels of the
plot, and inside de plot with "annotate_text".
This is an example of code:
r <- 1
label_R <- TeX(sprintf('$R = %i\\,\\mu Hz$', r), output = "character")
a <- ggplot(df, aes(x = myseq, y = mim)) + geom_line() +
annotate("text", x = 60 + 15, y = 0.04,
label = label_R, parse = T)
a
When I run the code, I get the following error messages
unused argument (output = "character")
+ label = label_R, parse = T)
1: $
^
I checked that "output = character" is not an option in TeX, however, if I
use no option within TeX
the object created has attribute "character" for output. In any case, all
the three options
"expression", "text", and "ast" yield the same error message.
If I turn parse option in annotate to "F", it displays the expression
without being parsed and no error.
So I think the problem comes from the parsing procedure, which might have
changed at some
of the latest ggplot updates or R updates.
Any idea? thanks in advance!
JC
PS: I run the code with the latest version of RStudio and R:
R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I have a bunch of R scripts doing plots with ggplot2 (nice package!). Since
I plot plenty of greek variables, I decided to use latex2exp package to
display greek character in ggplot2 plots.
This worked for me without any problem, but now it does not longer work. I
have been investigating if the problem may come from updates in the
packages, but
I am not able to find where is the problem.
The point is that I use greek chacarcters in both the x and y labels of the
plot, and inside de plot with "annotate_text".
This is an example of code:
r <- 1
label_R <- TeX(sprintf('$R = %i\\,\\mu Hz$', r), output = "character")
a <- ggplot(df, aes(x = myseq, y = mim)) + geom_line() +
annotate("text", x = 60 + 15, y = 0.04,
label = label_R, parse = T)
a
When I run the code, I get the following error messages
label_R <- TeX(sprintf('$R = %i\\,\\mu Hz$', r), output = "character")
Error in TeX(sprintf("$R = %i\\,\\mu Hz$", r), output = "character") :unused argument (output = "character")
a <- ggplot(df, aes(x = myseq, y = mim)) + geom_line() +
+ annotate("text", x = 60 + 15, y = 0.04,+ label = label_R, parse = T)
a
Error in parse(text = as.character(lab)) : <text>:1:1: unexpected '$'1: $
^
I checked that "output = character" is not an option in TeX, however, if I
use no option within TeX
the object created has attribute "character" for output. In any case, all
the three options
"expression", "text", and "ast" yield the same error message.
If I turn parse option in annotate to "F", it displays the expression
without being parsed and no error.
So I think the problem comes from the parsing procedure, which might have
changed at some
of the latest ggplot updates or R updates.
Any idea? thanks in advance!
JC
PS: I run the code with the latest version of RStudio and R:
R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.