How to plot bar plot with Chinese names in input file?

后端 未结 1 1906
故里飘歌
故里飘歌 2020-12-22 07:20

I want to plot a barplot from an input file having Chinese characters.

木材   2   2 
表     3   4
笔     4   2 
垃圾桶  5   6 
杯     6   3  

I ex

相关标签:
1条回答
  • 2020-12-22 08:06

    What problems do you have when you try to get this barplot? It works for me, at least what concerns the Chinise characters. Try

    mydata = matrix( c( 2:6, c( 2,4,2,6,3 ) ), nrow= 2 )
    mylabs = c( "木材", "表", "笔", "垃圾桶", "杯" )
    barplot( mydata, beside=T, horiz= "T", names.arg= mylabs, las= 1, col= c( "red", "blue" ) )
    

    enter image description here

    Maybe you have problems when you try to save the plot as pdf. In that case, try jpeg:

    jpeg( "plotname.jpg" )
    barplot( mydata, beside=T, horiz= "T", names.arg= mylabs, las= 1, col= c( "red", "blue" ) )
    dev.off()
    
    0 讨论(0)
提交回复
热议问题