Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201919

Plotting graphs from class `nb` - How to change points color?

$
0
0

It is easier to explain what am I trying to do through the following reproducible example:

library(sf)
library(brazilmaps)
library(spdep)

# loading cities map
cities_mg <- brazilmaps::get_brmap(geo        = 'City', 
                                   geo.filter = list(State = 31),
                                   class      = 'sf')

# creating adjacency matrix (neighborhood graph)
nb_mg <- spdep::poly2nb(cities_mg)

# plotting
coords_mg <- st_coordinates(st_centroid(st_geometry(cities_mg)))

par(bg = '#2E2E2E')
plot(nb_mg, coords_mg, pch = 19, cex = .6, lwd = .4, 
     col = '#00C040', points = T)

This piece of code generates the following plot enter image description here

What I would like to do, is coloring the nodes (or vertices) with the same color as the edges. Is it possible?

Thank you in advance.


Viewing all articles
Browse latest Browse all 201919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>