R 在绘图上创建第二个X轴
大家好 我有以下R 在绘图上创建第二个X轴,r,R,大家好 我有以下dataframe obj <- data.frame (percentile = c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6 , 0.7, 0.8, 0.9, 1), emp_change = c(0.05, 0.04, 0.03, 0.05, 0.06, 0.04, 0.02, 0.09, 0.08, 0.06), task = c("Manual", &
dataframe
obj <- data.frame (percentile = c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6 , 0.7, 0.8, 0.9, 1),
emp_change = c(0.05, 0.04, 0.03, 0.05, 0.06, 0.04, 0.02, 0.09, 0.08, 0.06),
task = c("Manual", "Manual", "Manual", "Routine-Manual", "Routine-Manual",
"Routine-Abstract", "Routine-Abstract", "Abstract", "Abstract", "Abstract"))
非常感谢
Freddy您是否尝试过使用
ggplot2::sec_axis
?这是获得第二个轴的标准(唯一?)方法。我很难想象这会是一个容易理解的情节。几乎所有关于第二个轴的请求都涉及第二个y变量,而不是第二个x轴。在查看了被提名者的副本并回顾了您的问题后,我认为您真正想要的是第二组轴标签,而不是第二个轴。
plot <- ggplot() +
geom_line(data = obj, aes(x= percentile, y= emp_change, group = 1, color="observed", linetype = "observed"),
size=1.5, linetype = "dotdash")
print(plot + theme(axis.text.x=element_text(angle = 60, hjust = 1)) +
theme(axis.title=element_text(size=12)) +
labs(y="100 x Change in Employment Share", x = "Percentile ranked by task input and log of mean occupational wage (1990)"))