If you create a Treemap with R, your Japanese will become garbled.

Asked 2 years ago, Updated 2 years ago, 68 views

data contains nouns (noun) and appearance rate % (freq), and I tried to create a Treemap with the following script, but all Japanese characters on the label (like □□) are garbled.
Could you tell me how to solve this problem?

library(treemap)
treemap(data, index=c("noun", "freq"),
    vSize = "freq",
    vColor="freq",
    type = "dens",
    palette = "RdYlGn", 
    fontsize.labels = 10 )

r garbled-characters

2022-09-30 16:21

1 Answers

In my Windows environment, the characterization does not occur, so it is not reproducible, but I think I can solve it by specifying the arguments of the fontfamily.xxx series in treemap().This answer is based on 's article which is good for your health.

The following is an example of a mac environment.

 treemap(res3, index=c("Term", "Freq"),
        vSize = "Freq",
        vColor="Freq",
        type = "dens",
        palette = "RdYlGn", 
        fontsize.labels = 10,
        fontfamily.labels="HiraKakuProN-W3",
        fontfamily.title="HiraKakuProN-W3",
        fontmail.legend="HiraKakuProN-W3")


2022-09-30 16:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.