如何在R中绘制羽毛图? [英] How can I make a feather plot in R?

查看:45
本文介绍了如何在R中绘制羽毛图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在R中绘制羽毛图?进行一些Google搜索时,只发现了一个可以制作羽毛图的R程序包( feather.plot ),但是它是一个旧程序包,不适用于R版本3.6.1.下面是我要绘制羽状图的风速和风向的时间序列的示例.x轴为 hour ,每根羽毛的长度应为 speed ,每根羽毛的角度应为 direction .

Is it possible to make a feather plot in R? Doing some google searches only turned up one R package (feather.plot) capable of making feather plots, however it is an old package that is not available for R version 3.6.1. Below is an example of a timeseries of wind speed and direction that I would like to make a feather plot with. The x-axis would be hour, the length of each feather should be speed, and the angle of each feather should be direction.

set.seed(123)

wind.df <- data.frame(hour = 1:10,
                      speed = runif(n=10, min = 1, max = 10),
                      direction <- runif(n=10, min = 0, max = 360))

推荐答案

这是我追求的最终产品,感谢@Allan Cameron的帮助

This was the final product I was after, thanks for your help @Allan Cameron

library(ggplot2)
library(tidyverse)
library(dplyr)

set.seed(123)

wind.df <- data.frame(hour = 1:10,
                      speed = runif(n=10, min = 1, max = 10),
                      direction <- runif(n=10, min = 0, max = 360))

wind.df %>%
  ggplot(aes(x = hour, y = 0, angle = direction, radius = speed)) +
  geom_spoke(size = 1,
               arrow = grid::arrow(length = unit(0.25, "cm"), type = "open")) +
  geom_hline(yintercept = 0, color = "gray50") +
  geom_point() +
  ylab(expression(paste("Absolute Wind Speed (m  ", s^-1,")"))) +
  ylim(-10,10) +
  scale_x_continuous(limits = c(0,12),
                     breaks = c(seq(from = 0, to = 10, by = 1))) +
  theme_bw() +
  theme(panel.grid = element_blank(),
        text = element_text(size = 12),
        axis.text.x = element_text(size = 12, color = "black"),
        axis.text.y = element_text(size = 12, color = "black"))

这篇关于如何在R中绘制羽毛图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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