【R问题】怎么在ggplot里显示中文。



  • Anyway to display the level of variable (district name) in Chinese instead of the UTF-8 code? See example below. Thanks,

    0_1474597257881_upload-d6edf05b-faf5-4991-85e5-7f08a6bc97ce


  • 太阁x英雄榜

    你好,如果希望在ggplot2中显示中文,需要在画图的时候设定family参数即可:

    library(ggplot2)
    ggplot(data.frame(x = rnorm(100))) +
    geom_histogram(aes(x), fill = ‘purple’, alpha = 0.6) +
    labs(x = ‘X 取值’, y = ‘频数 Count’) +
    theme(text = element_text(family = ‘SimSun’))

    0_1474618130330_upload-4e477f4d-26c5-41e4-9015-f735d9105512

    阅读更多:http://www.jianshu.com/p/4d3736ab2016



  • Thanks for the answer. Sorry I didn’t ask clearly. I was trying to ask how to label the tick value in Chinese, such as "浦东“ instead of “<U+5609…” for x-axis in the plot above. Many thanks,


  • 太阁x英雄榜

    @jingstat怎么在ggplot里显示中文。 中说:

    Thanks for the answer. Sorry I didn’t ask clearly. I was trying to ask how to label the tick value in Chinese, such as "浦东“ instead of “<U+5609…” for x-axis in the plot above. Many thanks,

    hmm 你好,很不好意思的说,这几天在本地测试使用中文显示tick,然而并没有成功 >.<
    我再试试其他方法,如果成功了马上回复你 =)

    ====================================

    10.10更新:

    遍寻无果,R语言可能是不支持用中文坐标轴标注。建议使用代号或者拼音替代进行标注。
    =)


 

与 BitTiger Community 的连接断开,我们正在尝试重连,请耐心等待