rigraph icon indicating copy to clipboard operation
rigraph copied to clipboard

Plotting Errors when Not All Attributes Assigned

Open billdenney opened this issue 7 years ago • 1 comments

When an attribute is assigned to a vertex, the plotting fails for reasons that appear to be related to not assigning default values to vertices (see the as_data_frame() output for what looks like the hint, to me).

library(igraph)
#> 
#> Attaching package: 'igraph'
#> The following objects are masked from 'package:stats':
#> 
#>     decompose, spectrum
#> The following object is masked from 'package:base':
#> 
#>     union
schema <- make_empty_graph() + vertices("c", "p1", "p2", color = "green", shape = "rectangle", 
  size = 30, size2 = 30)
plot(schema)

as_data_frame(schema, what = "vertices")
#>    name color     shape size size2
#> c     c green rectangle   30    30
#> p1   p1 green rectangle   30    30
#> p2   p2 green rectangle   30    30

schema <- make_empty_graph() + vertices("c", "p1", "p2", color = "green", shape = "rectangle", 
  size = 30, size2 = 30) + vertices("d")
plot(schema)
#> Error in igraph.check.shapes(params("vertex", "shape")): Bad vertex shape(s): NA.
as_data_frame(schema, what = "vertices")
#>    name color     shape size size2
#> c     c green rectangle   30    30
#> p1   p1 green rectangle   30    30
#> p2   p2 green rectangle   30    30
#> d     d  <NA>      <NA>   NA    NA

schema <- make_empty_graph() + vertices("c", "p1", "p2", color = "green", shape = "rectangle", 
  size = 30, size2 = 30) + vertices("d", shape = "circle")
plot(schema)
#> Error in plot.window(...): need finite 'xlim' values
as_data_frame(schema, what = "vertices")
#>    name color     shape size size2
#> c     c green rectangle   30    30
#> p1   p1 green rectangle   30    30
#> p2   p2 green rectangle   30    30
#> d     d  <NA>    circle   NA    NA

billdenney avatar Aug 27 '18 10:08 billdenney

Not sure if it's a genuine bug as the NA values should be filled before plotting, but I'm labelling it as a bug nevertheless in case we find an easy fix for it in the future that would let us handle NAs gracefully.

ntamas avatar Nov 03 '22 00:11 ntamas