【问题标题】:Increase axes labels size with barplot()使用 barplot() 增加轴标签大小
【发布时间】:2016-12-19 15:17:56
【问题描述】:

如何在以下条形图中增加 x 和 y 轴的大小?

我需要将 'freq''heights' 增加到例如cex = 2

df = read.table(text = 'Heights freq    
                             a  16  
                             b  9   
                             c  8   
                             d  6   
                             e  7   
                             f  4   
                             g  4   
                             h  2   
                             i  3   
                             l  1', header = TRUE)

    x = barplot(df$freq, cex.axis = 1.5, ylab = 'freq', xlab = 'heights')

    axis(1, at = x, c('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 
                      'h', 'i'), cex.axis = 1.5) #rename x-axis values

这可能看起来很傻,但我找不到办法。

谢谢

【问题讨论】:

    标签: r plot labels


    【解决方案1】:

    您只需将条形图代码中的cex.axis 更改为cex.lab

    df = read.table(text = 'Heights freq    
                             a  16  
                             b  9   
                             c  8   
                             d  6   
                             e  7   
                             f  4   
                             g  4   
                             h  2   
                             i  3   
                             l  1', header = TRUE)
    
    x = barplot(df$freq, cex.lab = 2, ylab = 'freq', xlab = 'heights')
    
    axis(1, at = x, c('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 
                      'h', 'i'), cex.axis = 1.5) #rename x-axis values
    

    【讨论】:

      猜你喜欢
      • 2014-03-04
      • 1970-01-01
      • 1970-01-01
      • 2020-07-10
      • 2015-10-16
      • 2021-03-11
      • 1970-01-01
      • 1970-01-01
      • 2015-08-08
      相关资源
      最近更新 更多