Skip to content

Loading…

Lines across world map #169

Closed
hadley opened this Issue · 4 comments

3 participants

@hadley
Owner
require(maps)
world <- data.frame(map("world", plot=FALSE)[c("x","y")])
ggplot( world, aes(x=x,y=y)) + geom_path( ) +coord_map()
@kloesing

Here's a workaround that looks like it fixes the problem, but that may cover the real bug or even introduce new problems. In the transform() function of CoordMap, change

out$x <- rescale(out$x, 0:1, details$x.range, clip = FALSE)

to

out$x <- rescale(out$x, 0:1, details$x.range, clip = TRUE)
@hadley
Owner

That sounds like a great feature, but unfortunately we don't currently have the development bandwidth to support it. If you'd like to submit a pull request that implements this feature, please follow the instructions in the development vignette.

@hadley hadley closed this
@restonslacker

This still seems like an issue. Is there a workaround that doesn't involve modifying ggplot2 function code?

  library(ggplot2)
  library(maps)
  eq_data <- structure(list(lon = c(-113.9671, -121.0526657, -114.4953, 42.6173,
                                    166.967, 71.3797, 46.8704, -98.6556, -98.65, 126.2017),
                            lat = c(-22.3828, 35.7091675, 44.5294, 37.9245, -14.542,
                                    36.6672, 33.5511, 36.4739, 36.5067, 3.4859),
                            depth = c(10, 6.67, 11.56, 28.27, 6.56, 90.65,
                                      10, 5, 8.5, 145.25),
                            magnitude = c(5.5, 3.26, 2.7, 4.3, 5.1, 5, 4.3, 2.6, 2.9, 4.3)),
                       .Names = c("lon", "lat", "depth", "magnitude"),
                       row.names = c(NA, 10L), class = "data.frame")

  ggplot(eq_data, aes(x=lon, y=lat))+geom_point()+
    geom_polygon(aes(x=long, y=lat, group = group),data=map_data("world"),colour="brown",size=1,alpha=0.5, fill="#ffffff")+
    ggtitle("Earthquakes, Last 7 days, Magnitude >=2.5")+coord_map()
@restonslacker

I guess adding an xlim argument to coord_map() sort of works...

  ggplot(eq_data, aes(x=lon, y=lat))+geom_point()+
    geom_polygon(aes(x=long, y=lat, group = group),data=map_data("world"),colour="brown",size=1,alpha=0.5, fill="#ffffff")+
    ggtitle("Earthquakes, Last 7 days, Magnitude >=2.5")+coord_map(xlim = c(-179.999999,179.999999))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.