bblonder / timeordered

Time-ordered network analyses (timeordered R package)
http://cran.r-project.org/package=timeordered
3 stars 0 forks source link

allow customization of plots with igraph #1

Open jalapic opened 6 years ago

jalapic commented 6 years ago

Hi - I really like your package. Thanks for compiling it. I have modified your plotnetworkslices() and plottanet() functions such that they allow for customized igraph plotting. Happy to add this as a pull request if you'd like to include it.

plotnetworkslices <- function (slices, timedeltas, ...) 
{
  timestrings <- paste(timedeltas[, 1], " - ", timedeltas[, 
                                                          2])
  par(mfrow = c(ceiling(sqrt(length(slices))), ceiling(sqrt(length(slices)))))
  par(mar = c(1, 1, 1, 1))
  for (i in 1:length(slices)) {
    plottanet(slices[[i]],...)
    text(0, 0, timestrings[i])
  }
}

plottanet <- function (timeaggregatednetwork, layout = layout.circle, vertex.label = V(timeaggregatednetwork)$name, 
          vertex.size = 0, vertex.label.cex = 0.5, edge.arrow.size = 0.5, 
          edge.width = E(timeaggregatednetwork)$Count/5, ...) 
{
  plot(timeaggregatednetwork, layout = layout, vertex.label = vertex.label, 
       vertex.size = vertex.size, vertex.label.cex = vertex.label.cex, 
       edge.arrow.size = edge.arrow.size, edge.width = edge.width, 
       vertex.label.family = "Helvetica", ...)
}

Example:

data(ants)

td500 <- generatetimedeltas(0,1500,500)
ns500 <- generatenetworkslices(g, td500)

plotnetworkslices(ns500, td500, edge.arrow.size = 0.2, layout=layout_nicely,
                   edge.color="tomato")

image

bblonder commented 6 years ago

Hi James,

Thanks for the idea. I have added this functionality and submitted to CRAN.

Ben

On Wed, Jun 27, 2018 at 11:06 AM, James Curley notifications@github.com wrote:

Hi - I really like your package. Thanks for compiling it. I have modified your plotnetworkslices() and plottanet() functions such that they allow for customized igraph plotting. Happy to add this as a pull request if you'd like to include it.

plotnetworkslices <- function (slices, timedeltas, ...) { timestrings <- paste(timedeltas[, 1], " - ", timedeltas[, 2]) par(mfrow = c(ceiling(sqrt(length(slices))), ceiling(sqrt(length(slices))))) par(mar = c(1, 1, 1, 1)) for (i in 1:length(slices)) { plottanet(slices[[i]],...) text(0, 0, timestrings[i]) } }

plottanet <- function (timeaggregatednetwork, layout = layout.circle, vertex.label = V(timeaggregatednetwork)$name, vertex.size = 0, vertex.label.cex = 0.5, edge.arrow.size = 0.5, edge.width = E(timeaggregatednetwork)$Count/5, ...) { plot(timeaggregatednetwork, layout = layout, vertex.label = vertex.label, vertex.size = vertex.size, vertex.label.cex = vertex.label.cex, edge.arrow.size = edge.arrow.size, edge.width = edge.width, vertex.label.family = "Helvetica", ...) }

Example:

data(ants)

td500 <- generatetimedeltas(0,1500,500) ns500 <- generatenetworkslices(g, td500)

plotnetworkslices(ns500, td500, edge.arrow.size = 0.2, layout=layout_nicely, edge.color="tomato")

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bblonder/timeordered/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/AAnvP_jRWzWSgxGnKF1vYxwPijqW5MwLks5uA7uZgaJpZM4U6EWf .

-- Benjamin Blonder Macrosystems Ecology Laboratory School of Life Sciences Arizona State University

Website: http://www.benjaminblonder.org Google Scholar: http://scholar.google.com/citations?user=l3FNoE8AAAAJ University of Arizona Sky School: https://skyschool.arizona.edu/