矢量场可视化R [英] vector field visualisation R

查看:115
本文介绍了矢量场可视化R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的文本文件,其中包含很多行.每行对应一个向量. 这是每一行的示例:

        x           y               dx              dy
99.421875   52.078125   0.653356799108  0.782479314511

前两列是向量开始的坐标.第二两列是坐标增量(终点减去起点). 我需要制作此矢量场的图片(所有矢量在一张图片上). 我该怎么办? 谢谢

解决方案

使用ggplot2,您可以执行以下操作:

library(grid) 
df <- data.frame(x=runif(10),y=runif(10),dx=rnorm(10),dy=rnorm(10))
ggplot(data=df, aes(x=x, y=y)) + geom_segment(aes(xend=x+dx, yend=y+dy), arrow = arrow(length = unit(0.3,"cm")))

这几乎直接来自geom_segment 帮助页面. /p>

I have a big text file with a lot of rows. Every row corresponds to one vector. This is the example of each row:

        x           y               dx              dy
99.421875   52.078125   0.653356799108  0.782479314511

First two columns are coordinates of the beggining of the vector. And two second columnes are coordinate increments (the end minus the start). I need to make the picture of this vector field (all the vectors on one picture). How could I do this? Thank you

解决方案

With ggplot2, you can do something like this :

library(grid) 
df <- data.frame(x=runif(10),y=runif(10),dx=rnorm(10),dy=rnorm(10))
ggplot(data=df, aes(x=x, y=y)) + geom_segment(aes(xend=x+dx, yend=y+dy), arrow = arrow(length = unit(0.3,"cm")))

This is taken almost directly from the geom_segment help page.

这篇关于矢量场可视化R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆