r - 在绘图上创建第二个 xaxis
问题描述
小伙子们,
我有以下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"))
task
我的目标也是在我的 x 轴上显示变量。我不知道是否有必要生成第二个 x 轴。我知道这个问题很简单,之前肯定有人问过,但我失败了,因为我只找到了条形图的解决方案。
这是我的阴谋。另请注意,我在真实数据中使用 geom_smooth 而不是 geom_line。但我想这在创建第二个 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)"))
提前谢谢了
弗雷迪
解决方案
推荐阅读
- linux - 如何确保托管服务提供商无法访问我的秘密?
- python - 如果每行用空格分隔,如何在多行文本字符串中实现左对齐?
- django - Django中的日期时间
- python - 字典问题(TypeError:字符串索引必须是整数)
- python-3.x - 记录已删除消息并检索执行程序的 Discord.py BOT
- erlang - Ejabberd 顺序与并行服务器
- javascript - D3.js v7 - 如何使 Y 轴标签始终显示在屏幕上以用于可滚动图表
- python - 如何按括号顺序将字符串分成块?
- mysql - 如何根据另一个列值连接 SQL 中的列值
- android - Dart Elipsis 在 else 之后