Skip to content
New issue

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

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

Already on GitHub? # to your account

Hebrew ggplot2 axis labels are removed when flextable is loaded #542

Open
matanhakim opened this issue May 18, 2023 · 0 comments
Open

Hebrew ggplot2 axis labels are removed when flextable is loaded #542

matanhakim opened this issue May 18, 2023 · 0 comments
Labels
bug grid-plot related to grid output

Comments

@matanhakim
Copy link

matanhakim commented May 18, 2023

Let's imagine I want to create a simple plot with ggplot:

library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.2.3

mtcars |> 
  ggplot(aes(factor(cyl))) +
  geom_bar() 

Created on 2023-05-18 with reprex v2.0.2

This is great.
Now, let's assume I would like to change the X axis labels to Hebrew. (The letters are equivalent to "A, B, C")

library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.2.3

mtcars |> 
  ggplot(aes(factor(cyl))) +
  geom_bar() +
  scale_x_discrete(labels = c("א", "ב", "ג"))

Created on 2023-05-18 with reprex v2.0.2

Again, This works perfectly.

On our third step, let's go back to English labels, but now load flextable.

library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.2.3
library(flextable)
#> Warning: package 'flextable' was built under R version 4.2.3

mtcars |> 
  ggplot(aes(factor(cyl))) +
  geom_bar()

Created on 2023-05-18 with reprex v2.0.2

Now comes the problem.
When I both load flextable and use Hebrew labels, the labels dissappear:

library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.2.3
library(flextable)
#> Warning: package 'flextable' was built under R version 4.2.3

mtcars |> 
  ggplot(aes(factor(cyl))) +
  geom_bar() +
  scale_x_discrete(labels = c("א", "ב", "ג"))

Created on 2023-05-18 with reprex v2.0.2

I have no idea what causes this, but since this is such a sneaky bug it took me about two hours to locate.
I feel this should be addressed.
Thanks for the package and the work around it!

> sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] flextable_0.9.1 ggplot2_3.4.2   reprex_2.0.2   
@davidgohel davidgohel added the bug label May 24, 2023
@davidgohel davidgohel added the grid-plot related to grid output label Feb 25, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug grid-plot related to grid output
Projects
None yet
Development

No branches or pull requests

2 participants