R/plot_biggraph_horizontal_si.R

#' Generates plot of large number of dependencies in relatively compart format
#' @param source_info Source information list
#' @param legend.tf Logical indicates whether to plot legend
#' @param title of graph
#' @param vertex.sizes of nodes representing files
#' @param vertex.dist Distance from vertex for labes
#' @param label.cex size of label text
#' @param xstreatch Aspect ratio
#' @param legend.cex Size of legen font
#' @return list with graph element and graph made for DAG layout
#' @export 
#' 
#' 

plot.biggraph.horizontal.si <- function(source_info,legend.tf=FALSE,title="Dependencies",vertex.sizes=c(10,0.5),vertex.dist=0,label.cex=0.75,xstretch=1,legend.cex=1){
  
  # plots the depedency tree described by g.all
  # does not plot names
  
  
  
#  add.vertex.shape("star", clip=igraph::igraph.shape.noclip,
#                   plot=mystar, parameters=list(vertex.norays=5))
  
  g.all <- get.project.info.si(source_info)$graph
  
  g.all.2 <- g.all
  V(g.all.2)$name <- paste0(1:length(V(g.all.2)$name),".",(V(g.all.2)$file))
  V(g.all.2)$old.name <- V(g.all)$name
  V(g.all.2)$color <- "white"
  tree.layout <- layout.sugiyama(g.all.2,attributes="all")
  
  g2 <- tree.layout$extd_graph
  
  V(g2)$shape <- ifelse(is.na(V(g2)$shape),"circle",V(g2)$shape)
  
  
  g2$layout[,2:1] <- g2$layout[,1:2]
  
  g2$layout[,1] <- (max(g2$layout[,1])-g2$layout[,1])*xstretch
  
  
  
  
  plot(g2,vertex.size=ifelse(!is.na(V(g2)$name),vertex.sizes[1],vertex.sizes[2]),main=title,vertex.label.dist=vertex.dist,vertex.label.cex=label.cex,vertex.label.color="red")
  
  
  if(legend.tf){
    plot.new()
    
    legend("center",legend=paste(V(g.all.2)$name,V(g.all.2)$old.name),col=V(g.all.2)$color,pch=16,cex=legend.cex)
  }
  
  return(list(gout=g2,g.key=g.all.2))
  
}
gelfondjal/IT2 documentation built on May 17, 2019, 12:15 a.m.