Open 419kfj opened 4 years ago
Dear Kazuo,
The problem is due to the name of the variables in the list ( | 地域 and | 犯罪 | ) | . So with the following lines of code, everything is fine: |
---|
library(FactoMineR) library(ggplot2) .tbl2.1 <- matrix(c(395, 2456,1758, 147, 153, 916, 694, 327, 1347),byrow=T,3,3, dimnames = list(var1=c("オスロ","中部地域","北部地域"), var2=c("強盗", "詐欺","破壊") ))
res.CA <- CA(.tbl2.1,graph=FALSE) p <- plot.CA(res.CA,title = "FactoMineR 2.0 で日本語") p <- p + theme_bw(base_family = "HiraKakuProN-W3") p # does not display Japanese char
Regards Francois Le 04/12/2019 à 12:38, kazuo fujimoto a écrit :
husson,
Thank you for your new release version 2.0 of FactoMiner. I am enjoying ggplot graphs.
But there is a problem. If I use Japanese charactors, plot.CA does not display them. I added the sample code below.
|library(FactoMineR) library(ggplot2) .tbl2.1 <- matrix(c(395, 2456,1758, 147, 153, 916, 694, 327, 1347),byrow=T,3,3, dimnames = list(地域=c("オスロ","中部地域","北部地域"), 犯罪=c("強盗", "詐欺","破壊") )) res.CA <- CA(.tbl2.1,graph=FALSE) p <- plot.CA(res.CA,title = "FactoMineR 2.0 で日本語") p <- p + theme_bw(base_family = "HiraKakuProN-W3") p # does not display Japanese char plot.CA(res.CA,graph.type = "classic",title="FactoMineR 2.0 で日本語") # classic display is OK. |
If this is not the bug, I hope you will inform me how to set Fonts.
regards
kazuo
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/husson/FactoMineR/issues/2?email_source=notifications&email_token=AB2XXYH3IW4N27UJE6RGRD3QW6JEXA5CNFSM4JVHJAIKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H57IZMA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2XXYHPNV2U3P3T74NCTJTQW6JEXANCNFSM4JVHJAIA.
-- Francois Husson Department Statistics & Computer science AGROCAMPUS OUEST 65 rue de St-Brieuc - 35042 RENNES Tel: +33 2 23 48 58 86 https://husson.github.io https://husson.github.io/
Thank you for your reply. I tried above change from "地域 and 犯罪" to " var1 and var2". But the results are the same.
I tried the original table with var name by Japanese, "地域 and 犯罪", on Windows 10. It works fine.
So now the problem depends on the environment, I think.
I forgot to write my usual environment. PC: MacBook OS: macOS Mojave 10.14.6 R version 3.6.1 (2019-07-05) -- "Action of the Toes" RStudio: Version 1.2.5019 FactoMineR version 2.0
I tried my first script and your script on RStudio and Plain R's Script file on Mac.(result were the same. It does not work.) And on Windows 10, I tried both scripts with Plain R's Script file. It worked fine.
Above are an intermediate report of this issue.
I am checking the Japanese font issues on macOS (with RStudio). (Of course, I am using Japanse fonts with ggplot on may macOS and RStudio.)
regard.
husson,
I tried to use "showtext" package. "showtext: Using Fonts More Easily in R Graphs" https://cran.rstudio.com/web/packages/showtext/vignettes/introduction.html
And I can use Japanese Font on plot.CA with graph.type="ggplot".
My environment:(same as previous message) PC: MacBook OS: macOS Mojave 10.14.6 R version 3.6.1 (2019-07-05) -- "Action of the Toes" RStudio: Version 1.2.5019 FactoMineR version 2.0
title: "plotCA-Font-OK.Rmd"
author: "kazuo fujimoto"
date: "12/8/2019"
output:
html_document:
fig_retina: 1
knitr::opts_chunk$set(echo = TRUE)
library(FactoMineR)
library(ggplot2)
library(showtext) # <--------- !
font_families() # <--------- !
showtext_auto() # <--------- !
.tbl2.1 <- matrix(c(395, 2456,1758,
147, 153, 916,
694, 327, 1347),byrow=T,3,3,
dimnames = list(地域=c("オスロ","中部地域","北部地域"),
犯罪=c("強盗", "詐欺","破壊") )) # I use Japanese var names
.tbl2.1 res.CA <- CA(.tbl2.1,graph=FALSE) p <- plot.CA(res.CA,title = "FactoMineR 2.0 で日本語") p
It works fine !
But I am just starting to use "showtext". So my understanding might be unclear ;-)
regards.
kazuo
I made a report on how to use Japanese Font with FactoMineR v2, graph.type="ggplot".
Usually I set "fig.showtext=TRUE" as chunk option and set "showtext_auto(TRUE) at the beginning.
Please see attached my report on how to use Japanese Variable and Category names.
husson,
Thank you for your new release version 2.0 of FactoMiner. I am enjoying ggplot graphs.
But there is a problem. If I use Japanese charactors, plot.CA does not display them. I added the sample code below.
If this is not the bug, I hope you will inform me how to set Fonts.
regards
kazuo