[英]R: How can I make a barplot with labels parallel (horizontal) to bars
In barplot, is it possible to make the labels parallel to the bars? 在条形图中,是否可以使标签与条形图平行?
Suppose we have the data frame called "data". 假设我们有一个名为“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
I want to make a barplot of PV with the Page column as the label. 我想用Page列作为标签来制作PV的条形图。
names <-data$Page
barplot(data$PV,main="Page Views", horiz=TRUE,names.arg=names)
Which Produces: 哪个产生:
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.
如果不可能,我愿意接受有关绘制此信息的其他方法的建议。
You can use the las
graphics parameter. 您可以使用
las
图形参数。 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)
ng
NG
esal = c(res$V3) esal = c(res $ V3)
ename = res$V2 barplot(esal, names.arg=ename, col=c(rainbow(length(esal))), xlab="Employee Name", ylab="Salary", main="Emp V/S Salary")
ename = res $ V2 barplot(esal,names.arg = ename,col = c(rainbow(length(esal))),xlab =“Employee Name”,ylab =“Salary”,main =“Emp V / S Salary” )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.