我有一个包含年份和一个数值变量的数据帧
df <- data.frame(years = c(1, 500, 1000, seq(1100, 2000, 100)),
numbers = sample(13))
library(ggplot2)
ggplot(df, aes(x = years, y = numbers)) +
geom_line()我如何才能在x轴上看到每个有序中断之间的相同距离?例如,公元1年和公元500年在绘图中的距离应该与公元1500年和公元1600年相同。
发布于 2020-10-13 05:22:07
您可以将年份绘制为一个因子:
ggplot(df, aes(x = factor(years), y = numbers, group = 1)) +
geom_line() +
labs(x = "years")

https://stackoverflow.com/questions/64325372
复制相似问题