Git Product home page Git Product logo

Comments (7)

thomasp85 avatar thomasp85 commented on August 9, 2024 3

I absolutely want a way to combine ggraph with maps. My current sentiment is that I'll wait for the native sf support that will arrive in the next version of ggplot2 rather than get tangled in with another extension

from ggraph.

boshek avatar boshek commented on August 9, 2024 1

Though I haven't tested it this RPub may be of interest here: https://rpubs.com/debasishb/298685

from ggraph.

maikol-solis avatar maikol-solis commented on August 9, 2024

I have the very same problem. It would be wonderful to be able to combine ggmap and ggraph.

from ggraph.

maikol-solis avatar maikol-solis commented on August 9, 2024

@thomasp85 Thanks for the update. In a future version of ggraph, Could it be possible download online maps (gmaps or osm) as ggmap does?

from ggraph.

thomasp85 avatar thomasp85 commented on August 9, 2024

This is unlikely to be part of ggraph as this is possibly out of scope. I'll wait with ruling this out completely until I start poking at the problem

from ggraph.

jeff-mettel avatar jeff-mettel commented on August 9, 2024

@Jim89 @thomasp85 - Similar to this request (which I would be happy to submit separately), would be enabling network functionality atop Leaflet mapping.

from ggraph.

jeffreyhanson avatar jeffreyhanson commented on August 9, 2024

I was looking for a way to plot graphs with sf objects as nodes and couldn't find any solutions online. Since this issue is vaugely related to the plotting of spatial object, I thought I would post a solution here in case any one is interested.

# load packages
library(tidygraph)
library(ggplot2)
library(sf)
library(tibble)

# make data
nodes <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
edges <- tibble(from = 1:5, to = 6:10, type = letters[1:5])

# make centroids
ctr <- as.data.frame(as(st_geometry(st_centroid(nc)), "Spatial")@coords)
names(ctr) <- c("x", "y")

# make graph 
g <- tbl_graph(nodes, edges)

# make plot
p <- ggraph(g, "manual", node.position = ctr) +
     geom_sf(aes(fill = AREA), data = nodes) +
     geom_edge_arc(aes(color = type))

# render plot
print(p)

result

from ggraph.

Related Issues (20)

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.