У меня есть этот код:Добавление метки к вспомогательной оси в R
# Plotting everything
plot(p1, col= "lightgreen", xlim=c(-2.5,4.5), ylim=c(0, 700), main="Daily Total Precipitation for AR and Oct-May", xlab="ln(x)" , ylab="Frequency", xaxt = "n") # first histogram
plot(p2, col="red", xlim=c(-2.5,4.5), ylim=c(0, 700), xaxt = "n" , add=T)
# Adding in text labels on top of the bars
text(x, y, paste(round(percents,2),"%"), cex=0.50, pos=3, offset=0.3, col="black")
axis(side=1, at=breaks) # new x-axis
# parameter that needs to be set to add a new graph on top of the other ones
par(new=T)
plot(x, percents, xlim=c(-2.5,4.5), type="l", col="yellow", lwd=3.0, axes=F, ylab=NA, xlab=NA)
axis(side=4, at=seq(0,100,by=10), col="yellow", col.axis="yellow") # additional y-axis
mtext("Percent", side=4, col="yellow")
# legend settings
legend("topleft", c("AR", "Oct-May"), lwd=10, col=c("red", "lightgreen"))
Который производит этот график:
И я не могу показаться, чтобы выяснить, как получить вторичный ярлыка оси y, чтобы отображаться в правильном положении. Любая помощь или предложения очень приветствуются.
Редактировать: Использование RStudio.
Вам необходимо включить некоторые данные, чтобы сделать эту проблему [воспроизводимой] (http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Определите 'p1',' p2, 'x',' y', 'percents'. Каков желаемый результат? – MrFlick