我已經包含了重現當前結果所需的資料和代碼。我有一個針對不同個體的圖表 (4),它們是不同年份收集的資料。我目前將 x 軸作為 Julian Dates,因此它顯示了每年的日期。
我想讓它只顯示 0-365 的 x 軸一次,而不是重復多年。有沒有好的方法來實作這一點?我想基本上我要問的是是否可以將這四條線壓縮成具有相同 x 軸和 y 軸的單個圖形?
library(ggforce)
library(dplyr)
library(lubridate)
df <- read.csv("https://raw.githubusercontent.com/jhnhng/Data/main/NSD_Figure.csv")
df$t2 <- as.POSIXct(df$t2)
ggplot(ind_steps, aes(x = t2, y = NSD))
labs(x = "Julian Date", y = "Net Squared Displacement")
geom_line() theme_bw()
theme(axis.text.x = element_text(angle = 90))
scale_x_datetime(date_breaks = '10 days', date_labels = '%j')
facet_wrap(~class, ncol = 1 , nrow = 4)
uj5u.com熱心網友回復:
df$t3 <- as.numeric(format(df$t2, "%j"))
然后
ggplot(df, aes(x = t3, y = NSD))
...
scale_x_continuous(breaks = scales::breaks_width(10))
...

轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/387227.html
上一篇:如何向堆積條形圖添加標簽
