hello im doing empty graph that each node should be by lattidue and longitude of the earhquak and node size is by magnatuide and color is by depth

icame up with something but the prbolome that layouts overshadow my graph heres my codes:

attach(quakes)

cutfor_graph=cut(depth,6)

data_for_graph=mutate(quakes,cutfor_graph)

eg=make_empty_graph(n=1000,directed = F)

plot.igraph(eg,layout=as.matrix(select(data_for_graph,lat,long)),vertex.color=data_for_graph$cutfor_graph,vertex.size=data_for_graph$mag*5, main="network of quakes")

legend("bottomleft",legend=levels(as.factor(cutfor_graph)),col = c("red","blue","black","yellow","orange","green"),lty=2,pch=20 , pt.cex = 4, cex = 1 )

# how do i clean my social network

**nirmo**#1

**andresrcs**#2

As you have been told on other posts before, please make your questions with a reprex, currently your example is not reproducible because you are not including the libraries you are using nider the output you are getting.

I'm going to make a the reprex for your question this time, because this makes easier for others to help you, but you can do the same by following this simple guide

https://community.rstudio.com/t/faq-how-to-do-a-minimal-reproducible-example-reprex-for-beginners/23061/1

```
library(igraph)
library(dplyr)
attach(quakes)
cutfor_graph=cut(depth,6)
data_for_graph=mutate(quakes,cutfor_graph)
eg=make_empty_graph(n=1000,directed = F)
plot.igraph(eg,layout=as.matrix(select(data_for_graph,lat,long)),vertex.color=data_for_graph$cutfor_graph,vertex.size=data_for_graph$mag*5, main="network of quakes")
legend("bottomleft",legend=levels(as.factor(cutfor_graph)),col = c("red","blue","black","yellow","orange","green"),lty=2,pch=20 , pt.cex = 4, cex = 1 )
```

^{Created on 2019-03-17 by the reprex package (v0.2.1)}

**Yarnabrina**#4

I'm unable to provide a solution for now, but I think one possible reason for the points to be so overlapping is that the nodes are not actually plotted by latitudes and longitudes. I think some shift of location and scale has taken place. You can check this by plotting the axes (see the limits of the `x`

and `y`

axes below, and compare with the ranges of `lat`

and `long`

):

```
library(igraph)
#>
#> Attaching package: 'igraph'
#> The following objects are masked from 'package:stats':
#>
#> decompose, spectrum
#> The following object is masked from 'package:base':
#>
#> union
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:igraph':
#>
#> as_data_frame, groups, union
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
attach(quakes)
cutfor_graph <- cut(x = depth,
breaks = 6)
data_for_graph <- mutate(.data = quakes,
cutfor_graph)
range(lat)
#> [1] -38.59 -10.72
range(long)
#> [1] 165.67 188.13
eg <- make_empty_graph(n = 1000,
directed = F)
plot.igraph(x = eg,
axes = TRUE,
layout = as.matrix(x = select(.data = data_for_graph,
lat,
long)),
vertex.color = data_for_graph$cutfor_graph,
vertex.size = data_for_graph$mag*5,
main = "network of quakes")
legend("bottomleft",
legend = levels(x = as.factor(x = cutfor_graph)),
col = c("red", "blue", "black", "yellow", "orange", "green"),
lty = 2,
pch = 20,
pt.cex = 4,
cex = 1)
```

**nirmo**#5

hey ty for the help but if you can see the colors of the legend are not match to the nodes

and how do i drop the blue lines of the layout that cover the dots ?

**Yarnabrina**#6

The colors can fixed if you use `vertex.color = rainbow(n = 6)`

instead of `vertex.color = data_for_graph$cutfor_graph`

inside the `plot.igraph`

function, and then `col = rainbow(n = 6)`

in the legend function.

I don't know about the blue lines.

**system**closed #8

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.