我想制作一个双y轴图,该图给出总入学人数和女性入学人数的左侧绝对数字变化,以及右侧女性入学人数的比例。
我已经获得将我想要的图形输出为png的代码,但是它不适合窗口。我尝试扩大输出文件的大小,但这只是扩大了输出而不是扩大了窗口。
png("UNDERSTEM1.png", width=700, height=700)
plot(x, y1, type = "b", frame = FALSE, pch = 20,
col = "black", xlab = "Year", ylab = "", ylim=c(0,11000000))
mtext("No. of Students", side=2, line=3)
lines(x, y2, pch = 20, col = 451, type = "b", lty = 1)
par(new = TRUE)
plot(y5, type = "l", xaxt = "n", yaxt = "n",
ylab = "", xlab = "", col = "red", ylim=c(0,100), lty = 2)
axis(side=4, seq(0, 100, 10), las=2)
mtext("Percentage", side=4, line=3)
legend("topleft", legend=c("STEM", "STEM FEMALE", "PERCENTAGE FEMALE"),
col=c("black", 451, "red"), lty=c(1, 1, 2), cex=1)
dev.off()
此输出是一个图形,该图形在右侧具有我想要的百分比值,但它截取了100的最后一个0的末尾,也没有显示百分比标签。