DominikRafacz/deepdep

Error: Insufficient values in manual scale. 6 needed but only 5 provided.

Closed this issue · 1 comments

deepdep::plot_dependencies(
  deepdep::deepdep(
    'INTERNAL_PKG', local = TRUE, depth = 5L,
    dependency_type = c('Suggests', 'Imports', 'Depends', 'LinkingTo')
  )
)

Gave me error:

Error: Insufficient values in manual scale. 6 needed but only 5 provided.
Run `rlang::last_error()` to see where the error occurred.

Can't make it fully reproducible, but the first step runs & plot_dependencies fails. I believe this is the relevant part of the deepdep output:

with(x, table(origin_level, dest_level))
            dest_level
origin_level   1   2   3   4   5
           0  10   0   0   0   0
           1  30  62   0   0   0
           2  79 112  82   0   0
           3  67 103  63  14   0
           4  10  11   8   2   2

this is the step of plot_dependencies that fails:

  g <- g + geom_node_point(aes(fill = factor(layer)), size = 3, 
    shape = 21, show.legend = FALSE) + geom_node_label(data = function(g) g[g[, 
    "labeled"], ], aes(label = name, fill = factor(layer)), 
    show.legend = FALSE, label.padding = unit(0.28, "lines")) + 
    scale_fill_manual(values = get_nodefill_default_scale()) + 
    labs(caption = paste0("Plot made with deepdep v", packageVersion("deepdep"), 
      " on ", format(Sys.time(), usetz = FALSE)))

The issue is:

get_nodefill_default_scale()

which returns 5 values, but

table(g$data$layer)
#  0  1  2  3  4  5 
#  1 10 37 44 13  2 

Hey, thanks for pointing that out!
At some point of package development, during making plots more appealing I've made a somewhat unjustified assumption that 5 layers of dependencies (and thus five colors) would be sufficient... Now there are two more colors in our original scale and if there is more than 7 layers of dependencies the default discrete ggplot2 scale is used.