[英]Bar-chart legend position (avoiding operlap) in R
I have the following kind of data: 我有以下几种数据:
A B C D E F
Series1 681968620 814707019 689302814 827844038 778849469 826532174
Series2 41507149 53403451 52857261 52319991 59246699 104253758
Series3 869316619 722165946 858134539 716641489 759754131 668183913
Series4 12642153 15158215 5140017 8629111 7170466 6464783
When I am plotting my bar chart, using the following command: 当我绘制条形图时,使用以下命令:
barplot(height = m,
beside=T, ylab = "Area (m^2)", col=colorcode,
legend.text = c("Series1", "Series2","Series3",
"Series4"),
args.legend = list(x = "topright"))
the legend overlaps with the bars present in the diagram. 图例与图中的条形重叠。 How can I place my legend properly, so that my graph looks good.
如何正确放置图例,以使图形看起来不错。
par(mfrow=c(1, 1), mar=c(5, 5, 4, 10))
barplot(height = m,
beside=T, ylab = "Area (m^2)", col=1:4,
legend.text = c("Series1", "Series2","Series3",
"Series4"),
args.legend = list(x ='topright', bty='n', inset=c(-0.25,0)))
If you don't want the scientific notation
on y-axis
, you can change the options
before running the code, for example 如果您不希望在
y-axis
使用scientific notation
,则可以在运行代码之前更改options
,例如
op <- options(scipen=999)
m <- structure(c(681968620L, 41507149L, 869316619L, 12642153L, 814707019L,
53403451L, 722165946L, 15158215L, 689302814L, 52857261L, 858134539L,
5140017L, 827844038L, 52319991L, 716641489L, 8629111L, 778849469L,
59246699L, 759754131L, 7170466L, 826532174L, 104253758L, 668183913L,
6464783L), .Dim = c(4L, 6L), .Dimnames = list(c("Series1", "Series2",
"Series3", "Series4"), c("A", "B", "C", "D", "E", "F")))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.