I always recommend users of the LSX package visualizing polarity words using textplot_terms()
because it allows them to explain intuitively what their fitted LSS models are measuring to others. I am using this function myself in my project on construction of a geopolitical threat index (GTI) for multiple countries that include China and Japan, but I noticed that plotting function does not work well on Windows when I was analyzing Chinese texts: some of the the words are renders using both serif and sans-serif fonts.
set.seed(1234)
textplot_terms(lss, highlighted = keyword)
I tried to force the function to use the SimHei font but I found it is only possible in the underlying ggplot2 functions. So, I added ...
to the function in the upcoming version of the LSX package (v1.3.2) to specify the font through the family
argument. Since ...
is passed simply to ggplot2::geom_text()
and ggrepel::geom_text_repel()
, we can also use arguments such as size
. Note that, on Windows, we need to load fonts using the extrafont
package before textplot_terms()
.
# extrafont::font_import() # need to run only once
extrafont::loadfonts(quiet = TRUE)
set.seed(1234)
textplot_terms(lss, highlighted = keyword, family = "SimHei")
I hope this change will help users of the package to analyze Chinese texts more easily and present the results to wider audiences.