mitchelloharawild / ggquiver Goto Github PK
View Code? Open in Web Editor NEWR package for quiver plots in 'ggplot2'
Home Page: http://pkg.mitchelloharawild.com/ggquiver
R package for quiver plots in 'ggplot2'
Home Page: http://pkg.mitchelloharawild.com/ggquiver
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
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)
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!
Automatic grid setup with function inputs
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.