感谢大神,按照您的方法,终于做出来了!您给的代码中有些小错误,但是瑕不掩瑜,以下是完整代码及效果图。
#正式绘图
par(mar=c(2,5,2,5),oma = c(0,0,0,0),mai=c(0.3,0.5,0.4,1),mfrow=c(1,1))# $mai[1] 0.4 1.0 0.4 1.0
plot3D::hist3D(x=x,y=1:(2*max(y)),z=z_ppi,colvar = z_measure,col=jet.col(n=100,alpha = 1)[start:end],facets = FALSE,expand=1,colkey = list(plot=TRUE,cex.clab=0.8,length=0.7,at=iri_threshold,labels=iri_threshold_label,cex.axis=0.7),axes=FALSE,
clab = "IRI - 措施",main=paste(facility_name,year,"年规划养护方案"),cex.main=0.9,scale=FALSE,phi = 40)
x.tick.locations <- seq(from=x[1],to=x[length(x)-1],by=1)
#x轴ticks
segments3D(x0=x.tick.locations, y0=rep(0.5, length(x.tick.locations)),z0=rep(0.5, length(x.tick.locations)),
x1=x.tick.locations, y1=rep(0.7, length(x.tick.locations)),z1=rep(1, length(x.tick.locations)), col="black",add = TRUE)
text3D(x.tick.locations-1, rep(-0.3, length(x.tick.locations)), rep(0, length(x.tick.locations)), labels=paste("K",x.tick.locations,sep=""),cex=0.6,add = TRUE)
text3D(mean(x.tick.locations), -1.5, 0, labels="桩号",cex=0.7,add = TRUE)
#y轴ticks
y.tick.locations <- 1:(2*max(y))
segments3D(x0=rep(max(x), length(y.tick.locations))-0.3, y0=y.tick.locations+0.7,z0=rep(0, length(y.tick.locations)),
x1=rep(max(x), length(y.tick.locations)), y1=y.tick.locations+0.7,z1=rep(-0.3, length(y.tick.locations)), col="black",add = TRUE)
text3D(rep(max(x)+0.1, length(y.tick.locations)),y.tick.locations+0.5,rep(0, length(y.tick.locations)), labels=c("下行4#","下行3#","下行2#","下行1#","上行1#","上行2#","上行3#","上行4#"),cex=0.6,add = TRUE)
text3D(max(x)+1.5, mean(y.tick.locations), 0, labels="车道",cex=0.7,add = TRUE)
#z轴ticks
z.tick.locations <- round(seq(from=min(z_ppi,na.rm = TRUE),to=max(z_ppi,na.rm = TRUE),length.out=5),1)
segments3D(x0=rep(min(x), length(z.tick.locations))+0.5, y0=rep(0, length(z.tick.locations)),z0=z.tick.locations+0.6,
x1=rep(min(x), length(z.tick.locations))+0.7, y1=rep(0.1, length(z.tick.locations)),z1=z.tick.locations+0.6, col="black",add = TRUE)
text3D(rep(min(x), length(z.tick.locations))-1,rep(0, length(z.tick.locations)),z.tick.locations, labels=z.tick.locations,cex=0.6,add = TRUE)
text3D(min(x)-1, 0, max(z.tick.locations)+1, labels="IRI",cex=0.7,add = TRUE)
#副标题
mtext(side=1, text=tmp2, cex=0.7)
附件列表