GithubHelp home page GithubHelp logo

mitchelloharawild / ggquiver Goto Github PK

View Code? Open in Web Editor NEW
50.0 50.0 3.0 6.89 MB

R package for quiver plots in 'ggplot2'

Home Page: http://pkg.mitchelloharawild.com/ggquiver

R 100.00%
ggplot2 plot quiver r velocity

ggquiver's People

Contributors

mitchelloharawild avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ggquiver's Issues

geom_quiver does not work together with geom_sf

I want to create a plot with geom_quiver() and underlie a map. This works in the given example, when using borders():

# Removing automatic scaling
ggplot(seals, aes(x=long, y=lat, u=delta_long, v=delta_lat)) +
  geom_quiver(vecsize=NULL) +
  borders("state")

but, I want to plot something similar using geom_sf() instead:

library(maps); library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
states <- sf::st_as_sf(map('usa', plot = FALSE, fill = TRUE))
ggplot() + geom_quiver(data=seals, aes(x=long, y=lat, u=delta_long, v=delta_lat), vecsize=NULL) + 
  geom_sf(data = states)
#> Error: $ operator is invalid for atomic vectors

Unfortunately, this throws up an error: $ operator is invalid for atomic vectors

No check for equal proportions in plot

I just encountered this case, it seems geom_quiver does not check if the dimensions are equal between X and Y. This causes a problem that the directions of the arrows do not correct. This is easily fixable by using coord_equal or coord_fixed but it might be good to warn users to do so. Maybe it can be checked if the coord inherits CoordFixed, maybe a check for the ratio would also be good? (The first plot is incorrect)

d<-data.frame(t=Sys.time()+(3600*1:4), x=1000*c(1,-1), y=1000*c(1,1,-1,-1))
require(ggplot2)
#> Loading required package: ggplot2
require(ggquiver)
#> Loading required package: ggquiver
ggplot(d)+geom_quiver(aes(x=t, y=0, u=y,v=x))

ggplot(d)+geom_quiver(aes(x=t, y=0, u=y,v=x))+coord_equal()

Created on 2022-03-07 by the reprex package (v2.0.1)

Computation failed in `stat_quiver()`: argument is of length zero

Hi!
Thanks for this great package. geom_quiver() is returning the following warning (with no output) when I try to reproduce the examples in the package:

Warning message:
Computation failed in `stat_quiver()`:
argument is of length zero 

I noticed the pkgdown documentation is showing the same error.

Reprex:

library(ggplot2)
library(ggquiver)
library(dplyr)

expand.grid(x=seq(0,pi,pi/12), y=seq(0,pi,pi/12)) %>%
  ggplot(aes(x=x,y=y,u=cos(x),v=sin(y))) +
  geom_quiver()

Thanks!

not arrow plot when using with qmplot

Hi,
I've tried to overlay arrows to a basemap as in this example:

library(ggmap)
library(dplyr)

wind_data <- wind %>% filter(between(lon, -96, -93) & between(lat, 28.7, 30))
qmplot(lon, lat, data=wind_data, extent="panel", geom = "blank", zoom=8, maptype = "toner-lite") +
geom_quiver(aes(u=delta_lon, v=delta_lat, colour = spd), center=TRUE)

but only the base map and the color scale are showing.
geom_quiver still works when overlaid on ggplot.

packageVersion('ggplot2') ‘3.3.5’
packageVersion('ggmap') ‘3.0.0’
packageVersion('ggquiver') ‘0.2.0’
platform x86_64-pc-linux-gnu
version.string R version 3.6.3 (2020-02-29)

Would it be something I need to update?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.