hrbrmstr / ggalt

:earth_americas: Extra Coordinate Systems, Geoms, Statistical Transformations & Scales for 'ggplot2'
https://cran.r-project.org/web/packages/ggalt/vignettes/ggalt_examples.html
Other
664 stars 98 forks source link

ggalt does not work with latest ggplot2 version #23

Closed ghost closed 7 years ago

ghost commented 8 years ago

With any of the ggplot2 extensions that I use, actually. Just filed the issue here. Hadley thinks it is a ggplot extensions developer issue.

hrbrmstr commented 8 years ago

I hadn't had a chance to test this since the new pre-release of ggplot and there does seem to be breaking changes (the missing aesthetics on geom_map() seem especially problematic). Thx for the note and the linked example.

bhaskarvk commented 8 years ago

Here's a reproducible code sample.

ensureCranPkg <- function(pkg) {
  if(!suppressWarnings(requireNamespace(pkg, quietly = TRUE))) {
    install.packages(pkg)
  }
}

ensureCranPkg('devtools')
ensureCranPkg('maptools')

ensureGithubPkg <- function(pkg) {
  devtools::install_github(pkg)
}

ensureGithubPkg('hadley/scales')
ensureGithubPkg('hadley/ggplot2')
ensureGithubPkg('hrbrmstr/ggalt')
ensureGithubPkg('hrbrmstr/albersusa')
ensureGithubPkg('jrnold/ggthemes')

library(maptools)
library(scales)
library(ggplot2)
library(ggalt)
library(albersusa)
library(ggthemes)
library(colormap)

us <- usa_composite()
us_map <- fortify(us, region="fips_state")

gg_usa <- ggplot(us@data, aes(map_id=fips_state,fill=pop_2014)) +
  geom_map(map=us_map, color='#ffffff', size=0.1) + 
  expand_limits(x=us_map$long,y=us_map$lat) +
  theme_map() +  
  theme(legend.position="right") 

# This works
gg_usa

# This gives error
# Error in gPathFromVector(names) : 
# a 'grob' path must contain at least one 'grob' name
gg_usa +
coord_proj(us_laea_proj) 
hrbrmstr commented 8 years ago

Thx. It's an issue deeper in ggplot2 (not my code) that I haven't had time to fix. They changed many of the aes params. They closed an issue there that I brought up but it needs to be re-opened. x and y are not setup as aes params and I've reproduced issues with coord_map() (the one that comes with ggplot2) that generate the same errors as this.

On Thu, Oct 20, 2016 at 4:09 PM, Bhaskar V. Karambelkar < notifications@github.com> wrote:

Here's a reproducible code sample.

ensureCranPkg <- function(pkg) { if(!suppressWarnings(requireNamespace(pkg, quietly = TRUE))) { install.packages(pkg) } }

ensureCranPkg('devtools') ensureCranPkg('maptools') ensureGithubPkg <- function(pkg) { devtools::install_github(pkg) }

ensureGithubPkg('hadley/scales') ensureGithubPkg('hadley/ggplot2') ensureGithubPkg('hrbrmstr/ggalt') ensureGithubPkg('hrbrmstr/albersusa') ensureGithubPkg('jrnold/ggthemes')

library(maptools) library(scales) library(ggplot2) library(ggalt) library(albersusa) library(ggthemes) library(colormap) us <- usa_composite()us_map <- fortify(us, region="fips_state") gg_usa <- ggplot(us@data, aes(map_id=fips_state,fill=pop_2014)) + geom_map(map=us_map, color='#ffffff', size=0.1) + expand_limits(x=us_map$long,y=us_map$lat) + theme_map() + theme(legend.position="right")

This worksgg_usa

This gives error# Error in gPathFromVector(names) : # a 'grob' path must contain at least one 'grob' namegg_usa +

coord_proj(us_laea_proj)

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/hrbrmstr/ggalt/issues/23#issuecomment-255213988, or mute the thread https://github.com/notifications/unsubscribe-auth/AAfHtj5-i6UqrtxqS9bZXe2NKRKBDHSOks5q18p0gaJpZM4KMwFz .

juliasilge commented 7 years ago

I am running into this as well when trying to use coord_proj, which is so useful and great and wonderful.

The error I get is:

Error in gPathFromVector(names) : 
  a 'grob' path must contain at least one 'grob' name

I get this error when using coord_proj() but not coord_map(), FYI.