[英]Barplot make labels horizontal
I know this must be very basic, but this command:我知道这一定是非常基本的,但是这个命令:
barplot(df$var, horiz = T)
Is producing this chart:正在制作这张图表:
Yes, I've read the documentation of ?barplot
and searched and tried lots of different parameter setting, like beside
, names.arg
, etc. but I can't make the y labels text horizontal as I'd assume it would be natural once the chart is horizontal.是的,我已经阅读了
?barplot
的文档并搜索并尝试了许多不同的参数设置,例如beside
、 names.arg
等,但我无法将 y 标签文本设置为水平,因为我认为这很自然一旦图表是水平的。
I did try as per DaveT:我确实按照 DaveT 尝试过:
barplot(x$value, horiz = T, las=2)
Which now crops the labels text:现在裁剪标签文本:
Can anyone help?任何人都可以帮忙吗?
You need to add the "las" option to the function:您需要在 function 中添加“las”选项:
barplot(x$value, horiz = T, las=2)
Rstudio has this helpful cheat sheet posted on their website: https://github.com/rstudio/cheatsheets/raw/master/how-big-is-your-graph.pdf Rstudio 在他们的网站上发布了这个有用的备忘单: https://github.com/rstudio/cheatsheets/raw/master/how-big-is-your-graph.Z437175BA4191210EE004E1D93749
par(mar=c(5,8,4,2) + 0.1) # Doubles left margin.
[draw your plot]
par(mar=c(5,4,4,2) + 0.1) # Restore default
If 8 is still too small, try a larger value.如果 8 仍然太小,请尝试更大的值。 See?par for details.
有关详细信息,请参阅?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.