R:如何制作带有平行于(水平)条形标签的条形图 [英] R: How can I make a barplot with labels parallel (horizontal) to bars

查看:217
本文介绍了R:如何制作带有平行于(水平)条形标签的条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在barplot中,是否可以使标签与条形平行?

In barplot, is it possible to make the labels parallel to the bars?

假设我们有一个名为"data"的数据框.

Suppose we have the data frame called "data".

              Page   PV UniquePgv
1 /photos/upcoming 5295      2733
2                / 4821      2996
3          /search 1201       605
4       /my_photos  827       340
5   /photos/circle  732       482

我想用Page列作为标签制作PV的图.

I want to make a barplot of PV with the Page column as the label.

names <-data$Page
barplot(data$PV,main="Page Views", horiz=TRUE,names.arg=names)

哪种产品:

每个条的名称是垂直的,而条是水平的.

The name of each bar is vertical, while the bars are horizontal.

如何使标签水平和平行于条形显示?如果不可能的话,我愿意提出其他方法来绘制此信息的建议.

How can I make the labels display horizontally and parallel with the bars? If it is not possible, I am open to suggestions for other ways to plot this information.

推荐答案

您可以使用las图形参数.但是,如果这样做,名称将在窗口末尾消失,因此您需要更改页边距.例如:

You can use the las graphics parameter. However, if you do that, the names will run off the end of the window, so you need to change the margins. For example:

par(mai=c(1,2,1,1))
barplot(data$PV,main="Page Views", horiz=TRUE,names.arg=names,las=1)

这篇关于R:如何制作带有平行于(水平)条形标签的条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆