我有一个问题,格式化x轴的时间。ggplot2轴作为时间与1小时的错误
这是我的数据样本:
dput(x)
structure(list(Sample = c("BK01", "BK02", "BK03", "BK04", "BK05",
"BK06", "BK07", "BK08", "BK09", "BK10", "BK11", "BK12", "BK13",
"BK14", "BK15", "BK16", "BK17", "BK18", "BK19", "BK20", "BK21",
"BK22", "BK23", "BK24", "BK25", "BK26", "BK27", "BK28", "BK29",
"BK30", "BK31", "BK32", "BK33"), Breath.d13C = c(-25.62, -27.45,
-26.87, -25.21, -26.01, -24.33, -24.45, -23.73, -25.05, -26.11,
-27, -26.28, -24.62, -26.96, -24.55, -24.52, -21.24, -26.18,
-24.82, -26.12, -27.28, -26.5, -24.46, -22.83, -27.28, -25.55,
-27.12, -24.46, -23.07, -28.35, NA, -25.98, -26.64), Chms = structure(c(1470047400,
1470048300, 1470048300, 1470049200, 1470050100, 1470050100, 1470040200,
1470041100, 1470040200, 1470041100, 1470065400, 1470063600, 1470063600,
1470064500, 1470061800, 1470045600, 1470045600, 1470046500, 1470047400,
1470066300, 1470060000, 1470058200, 1470057300, 1470047400, 1470042000,
1470042000, 1470041100, 1470041100, 1470040200, 1470043800, NA,
1470060000, 1470039300), class = c("POSIXct", "POSIXt"), tzone = "")), class = "data.frame", row.names = c(NA,
-33L), .Names = c("Sample", "Breath.d13C", "Chms"))
我想用GGPLOT2打造Breath.d13C的VS中药真实性(收集时间)的图表。
library(ggplot2)
ggplot(x, aes(x=Chms,y=Breath.d13C)) +
geom_point() +
scale_y_continuous(name=expression(delta^13*C["Breath"]*" "("\u2030")),
limits=c(-30,-10),
breaks=seq(-30,-10,5),
labels=fmt_decimals(1)) +
scale_x_datetime(name="Collection Time",
labels = date_format("%H:00",tz="UTC"),
date_breaks = "1 hour") +
my_theme
此代码给我。然而,时间不到一个小时。 我可以通过检查Chms
列或使用正常[R地块
与此代码中看到这一点:
plot(x$Chms,x$Breath.d13C,cex=0.8)
两个地块使用相同的数据集,所以我不知道是什么引起的错误ggplot2
。不过,我想继续使用它。关于我做错什么的想法?
预先感谢您
'错误check_breaks_labels(休息,标签):找不到功能 “fmt_decimals”'。您是否使用了这个函数:'fmt_dcimals < - 函数(小数= 0){返回一个可以格式化 #轴标签的函数 function(x)as.character(round(x,decimals )) }'而且,my'the_theme'是什么? – Miha