我有一個腳本
combined_co2%>%
rename(carbon_dioxide_ppmv=co2)%>%
ggplot(mapping =aes(x = yrBP, y = carbon_dioxide_ppmv))
geom_line()->g_line
g_line
annotate( geom ="curve",
x = 2e 05,
y = 400,
xend = 280,
yend = 400,
curvature = 0.3,
arrow = arrow(length=unit(1.5, "mm")),
alpha = 0.8,
colour = "#00BFC4") ->g_curve
g_curve
annotate(
geom = "text",
x = 3e 05,
y = 400,
label = "2021 average:400 ppmv",
hjust = 0.1, vjust = -0.1,
lineheight = 0.8,
colour= "#00BFC4"
)
此腳本生成以下圖表

現在我試圖翻轉 x 軸來獲得下面的圖表:

我怎樣才能做到這一點?我嘗試了多次排序和排序但無濟于事
uj5u.com熱心網友回復:
沒有任何資料,只能給出一個通用的解決方案,你可以試試這個:
library(ggplot2)
set.seed(123)
# some fake data
df <- data.frame(x = 1900:2000, y =rnorm(101) )
ggplot(df, aes(x = x, y = y)) geom_line() scale_x_reverse()

沒有scale_x_reverse():

轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/328835.html
上一篇:如果組內所有缺失值,R替換缺失值
