Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
#import onetrain data
edges <- onetrain
edges #edges.minlen doesn't seem to do much in final viz
# Create a 'nodes' data frame
mynodes <- unique(c(as.character(edges[,1]), as.character(edges[,2])))
nodes <- data.frame(nodes=mynodes,
style = rep("filled", length(mynodes)),
fillcolor = c(rep("red", 37), rep("yellow", 2), "red",
rep("orange", 2), "purple", "gray55", "orange", rep("blue", 2), "red",
rep("blue", 2))
nodes$fontcolor <- c(rep("white", 37), rep("black", 2), rep("white", 11))
# Create the graph
### tried using graph paramaters 'mindist' and 'nodesep' to try and minimize
### the overlap between nodes (e.g. Times Square and its neighbors)
### but with 'overlap=true' they seem irrelevant
### making overlap=false leads to a linear graph that doesn't look that good (imo)
graph two_df {
# Graph statements
graph [layout = neato, overlap = true]
# Node statements
node [shape = circle, fontsize = 15, width = .9, fixedsize = true]
# Substitution with 'graphviz_nodes_edges_df' function
[1]: graphviz_nodes_edges_df(nodes_df = nodes, edges_df = edges, directed = FALSE)
### Data

This comment has been minimized.

Copy link
Owner Author

@jalapic jalapic commented Feb 21, 2015

The resulting graph looks ok, it's actually very good to visualize the express stops south of Penn - but I'd like to find ways to pull apart some of the more clustered nodes (e.g. Times Sq) without making the diagram becoming chaotic and very zig-zaggy.


This comment has been minimized.

Copy link

@rich-iannone rich-iannone commented Feb 21, 2015

Looks great! I have some ideas/suggestions:

  • use fontname = Helvetica for that MTA signage look
  • try using ports if you need to orient nodes... You can specify which Cardinal direction edges emit from and connect to
  • millennia should provide some necessary spacing; I wonder why it doesn't here. I'll look I to it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment