davidgohel / flextable

table farming
https://ardata-fr.github.io/flextable-book/
553 stars 80 forks source link

The picture in Rstudio is displayed in Chinese - ragg need to be used #579

Open JTCDCTWB opened 11 months ago

JTCDCTWB commented 11 months ago

As a user of Officeverse,I am really grateful for your contributions!

Meanwhile, a BUG was found during application, that is after loading any package of "flextable", "officer" and "officedown", the images with Chinese characters could not be plotted into Chinese in Rstudio. If the images with Chinese characters was plotted first, then loading the above three packages, everything is OK.

R:4.3.1; Rstudio:2023.09.0 Build 463; Operating System:Win11(22H2) or Win10(LTSC 2019 21H2)

Looking forward to your reply at your earliest convenience.

library(tidyverse) library(flextable) library(officer) tibble(性别 = c("男","女"),人数 = c(69,59)) %>% ggplot(aes(性别,人数)) + geom_point()

1

Restart Rstudio

library(tidyverse) tibble(性别 = c("男","女"),人数 = c(69,59)) %>% ggplot(aes(性别,人数)) + geom_point() library(flextable) library(officer)

2

davidgohel commented 11 months ago

hello,

What happen if you use ragg in RStudio default plot settings? Does it solve the issue?

Capture d’écran 2023-10-13 à 07 37 38

KR

JTCDCTWB commented 11 months ago

Thank you very much for your warm reply! According to your suggestion the problem was solved!

At 2023-10-13 13:38:23, "David Gohel" @.***> wrote:

hello,

What happen if you use ragg in RStudio default plot settings? Does it solve the issue?

KR

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

JTCDCTWB commented 10 months ago

*Thank you so much for your work!

Draw pictures in "officedown" with word exported in Chinese, sometimes the picture is not displayed, sometimes the Chinese is not displayed. The code is as follows:

output:

officedown::rdocx_document:



library(ggplot2)

df <- data.frame(性别 = c("男","女"),

                 人数 = c(48,45))

ggplot(df,aes(x = 性别,y = 人数,fill = 性别)) +

  geom_bar(stat = "identity")

1

2

Operating environment:

Windows 11 22H2

R version 4.3.1

Rstudio version 2023.09.0 Build 463

officedown version 0.3.1

The above problems have been reported to officedown

At 2023-10-13 13:38:23, "David Gohel" @.***> wrote:

hello,

What happen if you use ragg in RStudio default plot settings? Does it solve the issue?

KR

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

davidgohel commented 10 months ago

What happen if you use ragg in knitr settings? Does it solve the issue?

knitr::opts_chunk$set(dev="ragg_png")
JTCDCTWB commented 10 months ago

Thank you!Problem solved.

davidgohel commented 10 months ago

The issue (not solved or not documented yet) will need some work. Package 'ragg' is used by flextable, but I don't understand why it conflicts with your environment. This has already been reported. I will close the issue when it will be solved. Thank you for opening the issue!