我觉得你的痛苦 - 不得不之前重新创建地块。即使它曾经在SAS一次
如果它是一次性,我很想去老派。是这样的:
# Generate some data
someData <- data.frame(Year = 1987:2009,
mCases = rpois(23, 3),
pVac = sample(55:80, 23, T))
par(mar = c(5, 5, 5, 5))
with(someData, {
# Generate the barplot
BP <- barplot(mCases, ylim = c(0, 18), names = Year,
yaxt = "n", xlab = "", ylab = "Measles cases in Thousands")
axis(side = 2, at = 2*1:9, las = 1)
box()
# Add the % Vaccinated
par(new = T)
plot(BP, pVac, type = "l", ylim = c(0, 100), axes = F, ylab = "", xlab = "")
axis(side = 4, las = 1)
nudge <- ifelse(pVac > median(pVac), 2, -2)
text(BP, pVac + nudge, pVac)
mtext(side = 4, "% Vaccinated", line = 3)
par(new = F)
})
你需要包含一些示例数据 – jeremycg
有点复杂,但看看这双Y轴图:HTTPS: //rpubs.com/kohske/dual_axis_in_ggplot2 – ALKI
谢谢,@Chani。这是一个好的开始。我会尝试用这种方法搞乱。 – micturalgia