我绘制了下图,但无法调整秒Y轴的标签。有没有人知道这是怎么可能的?
我的右手Y轴也有1到14 * 10 ^ 8的限制,但是当我设置它时,它只从零到1.4。找不到原因!
以下是我用来制作情节的代码
fdic <- data.frame(matrix(scan(text ="1 16.70833333 1329877000
2 17.20370370 1118256000
3 16.61111111 1047726000
4 19.05555556 972202000
5 15.50925926 269648386
6 0.07407407 248606000
7 3.00925926 220576899
8 5.83796296 188132575"), 8, 3, byrow = T))
colnames(fdic) <- c("id", "botnets_per_wk", "Deposits")
plot <- plot(fdic$id, fdic$botnets_per_wk, pch=16, axes=FALSE, ylim=c(0,25), xlab="", ylab="",
type="l",col="dark blue")
axis(2, col="black",las=1)
mtext("Average # of botnets attacking banks per week",side=2,line=2.5)
box()
par(new=TRUE)
plot(fdic$id, fdic$Deposits, pch=15, xlab="", ylab="", ylim=c(1,1400000000),
axes=FALSE, type="l", col="red")
mtext("Deposits (USD, logged)",side=4,col="red",line=4)
axis(4, ylim=c(1,1400000000), col="black",col.axis="black",las=1)
axis(1,at = seq(1, 50, by = 1))
mtext("bank",side=1,col="black",line=2.5)
legend("topleft",legend=c("Average # of botnets attacking banks per week","Deposits"),
text.col=c("black","red"),pch=c(16,15),col=c("black","red"))
答案 0 :(得分:1)
实际上你看到的“1.4”是1.4e+09
,是14亿的科学记数法。使用options(scipen=999)
关闭R中的科学记数法(重新启动R后重置),然后用par(mai=c(...))
调整左边距,使长数字完全可见:
fdic <- data.frame(matrix(scan(text ="1 16.70833333 1329877000
2 17.20370370 1118256000
3 16.61111111 1047726000
4 19.05555556 972202000
5 15.50925926 269648386
6 0.07407407 248606000
7 3.00925926 220576899
8 5.83796296 188132575"), 8, 3, byrow = T))
colnames(fdic) <- c("id", "botnets_per_wk", "Deposits")
options(scipen=999)
par(mai = c(1, 1, 1, 2))
plot <- plot(fdic$id, fdic$botnets_per_wk, pch=16, axes=FALSE, ylim=c(0,25), xlab="", ylab="", type="l",col="dark blue")
axis(2, col="black",las=1)
mtext("Average # of botnets attacking banks per week",side=2,line=2.5)
box()
par(new=TRUE)
plot(fdic$id, fdic$Deposits, pch=15, xlab="", ylab="", ylim=c(1,1400000000), axes=FALSE, type="l", col="red")
mtext("Deposits (USD, logged)",side=4,col="red",line=4)
axis(4, ylim=c(1,1400000000), col="black",col.axis="black",las=1)
axis(1,at = seq(1, 50, by = 1))
mtext("bank",side=1,col="black",line=2.5)
legend("topleft",legend=c("Average # of botnets attacking banks per week","Deposits"), text.col=c("black","red"),pch=c(16,15),col=c("black","red"))
但实际上我会留下1.4
- 比例并将该轴标记为“存款(十亿美元,已记录)”,因为那些带有多个零的长数字很难阅读(我必须把手指放在它们上面并计算零,你不希望你的读者必须这样做。)