使用barplot()增加轴标签大小

问题描述 投票:0回答:1

如何在以下条形图中增加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个回答
1
投票

你只需要在barplot代码中将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
© www.soinside.com 2019 - 2024. All rights reserved.