相关疑难解决方法(0)

ggplot2带箭头/向量的风时间序列

根据气象数据(温度,风和湿度的小时值),我设法绘制了风速和风向的时间序列.现在我想在时间序列图上添加风向量.在这里你可以看到我想要的输出(在实际情节上绘制的箭头).

在此输入图像描述

我正在使用ggplot2,一直在查看stackoverflow,ggplot2包文档(将继续)但找不到解决方案.任何想法或指示在哪里看都是一个起点.

提前致谢

编辑问题 正如@slowlearner在评论中所建议的那样,我在这里添加代码和数据以制作可重现的示例.貌似geom_segment可以做到这一点.我设法在geom_segment中计算yend但是无法弄清楚如何找到xend,因为x轴是时间轴.我有风速和风向数据,所以我可以计算geom_segment的x,y风成分,但x需要转换为时间格式.

这是用于绘图(温度)和数据的代码

for (i in 1:2 ) {

rams=subset(data,data$stat_id %in% i)
tore=subset(torre,torre$stat_id %in% i)

# Gràfica en ggplot

# Gráfica de evolución temporal de las estaciones de la zona

gtitol=places$nom[places$stat_id == i]

myplot=ggplot(data=rams,aes(x=datetime, y=tempc, colour="RAMS")) +
  geom_line()  +  ylab("Temperatura (ºC)") + xlab(" ") + 
  ggtitle(gtitol) + theme(legend.title=element_blank()) + theme(legend.position="bottom") +
  scale_y_continuous(limits = c(0,40)) +
  geom_line(data=tore,aes(x=datetime,y=temp,colour = "Torre")) 
#scale_y_continuous(breaks = round(seq(min(data$tempc), max(data$tempc), by = 2),0))


ggsave(myplot,filename=paste("RAMS-",i,".png",sep=""),width=7.78,height=5.79)

}
Run Code Online (Sandbox Code Playgroud)

我尝试了geom_segment文档

p=ggplot(tore, aes(x =datetime, y = 5))
p + …
Run Code Online (Sandbox Code Playgroud)

r time-series ggplot2

8
推荐指数
1
解决办法
3954
查看次数

R 使用 ggplot2 geom_spoke 绘制膨胀方向箭头

我正在尝试绘制膨胀方向(md$Swell.Dir 和 height(md$m) 以便结果是类似于下面的图形;

风向&波高

这是我使用 dput 的数据的一个小样本;

md <- structure(list(UTC = structure(1:6, .Label = c("01-Feb-17 1200", 
"01-Feb-17 1500", "01-Feb-17 1800", "01-Feb-17 2100", "02-Feb-17 0000", 
"02-Feb-17 0300", "02-Feb-17 0600", "02-Feb-17 0900", "02-Feb-17 1200", 
"02-Feb-17 1500", "02-Feb-17 1800", "02-Feb-17 2100", "03-Feb-17 0000", 
"03-Feb-17 0300", "03-Feb-17 0600", "03-Feb-17 0900", "03-Feb-17 1200", 
"03-Feb-17 1500", "03-Feb-17 1800", "03-Feb-17 2100", "04-Feb-17 0000", 
"04-Feb-17 0300", "04-Feb-17 0600", "04-Feb-17 0900", "04-Feb-17 1200", 
"04-Feb-17 1500", "04-Feb-17 1800", "04-Feb-17 2100", "05-Feb-17 0000", 
"05-Feb-17 0300", "05-Feb-17 0600", "05-Feb-17 0900", "05-Feb-17 1200", …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

5
推荐指数
1
解决办法
1195
查看次数

标签 统计

ggplot2 ×2

r ×2

time-series ×1