Question

I'm making a dynamically generated graph of my lab experiments. This is what it looks like now:

experiments graph

Ideally I'd like the blue nodes to be in a line across the top, so that current experiments are visible no matter how big the history leading up to them gets. Is there a way to do that in GraphViz? I'm using PyDot, but also open to manually editing the Dot graph.

I found a possibly related question here, would putting them in a subgraph help?

EDIT: Here's the current dot code.

digraph depgraph {
rankdir=BT;
dpi=400;
"/experiments/2013-12-19_planmacro" [shape=rectangle, href="/experiments/2013-12-19_planmacro", fontsize=11, color="#61BD4D", label="Plan 96-well plate montage macro", penwidth=2];
"/experiments/2013-07-01_fluoromax" [shape=rectangle, href="/experiments/2013-07-01_fluoromax", fontsize=11, color="#cccccc", label="Testing OD730", penwidth=2];
"/experiments/2013-06-12_cloning" [shape=rectangle, href="/experiments/2013-06-12_cloning", fontsize=11, color="#cccccc", label="Re-cloning TFs", penwidth=2];
"/experiments/2014-01-02_startwt" [shape=rectangle, href="/experiments/2014-01-02_startwt", fontsize=11, color="#61BD4D", label="Start WT Cultures", penwidth=2];
"/experiments/2013-06-04_learning" [shape=rectangle, href="/experiments/2013-06-04_learning", fontsize=11, color="#cccccc", label="Learning R + Bioconductor", penwidth=2];
"/experiments/2013-07-xx_induction" [shape=rectangle, href="/experiments/2013-07-xx_induction", fontsize=11, color="#61BD4D", label="induction again", penwidth=2];
"/experiments/2013-06-04_bg11" [shape=rectangle, href="/experiments/2013-06-04_bg11", fontsize=11, color="#cccccc", label="BG11 Media + Plates", penwidth=2];
"/experiments/2013-06-13_chipseq" [shape=rectangle, href="/experiments/2013-06-13_chipseq", fontsize=11, color="#61BD4D", label="ChIP-Seq Mini-Preps", penwidth=2];
"/experiments/2013-06-06_cloning" [shape=rectangle, href="/experiments/2013-06-06_cloning", fontsize=11, color="#cccccc", label="Re-Cloning TFs", penwidth=2];
"/experiments/2013-06-21_cleaning" [shape=rectangle, href="/experiments/2013-06-21_cleaning", fontsize=11, color="#cccccc", label="cleaning day", penwidth=2];
"/experiments/2013-12-15_rnaextraction" [shape=rectangle, href="/experiments/2013-12-15_rnaextraction", fontsize=11, color="#cccccc", label="Another RNA extraction to test TRI:pellet ratios", penwidth=2];
"/experiments/2013-09-27_iptgplates" [shape=rectangle, href="/experiments/2013-09-27_iptgplates", fontsize=11, color="#61BD4D", label="IPTG Plates", penwidth=2];
"/experiments/2013-06-03_growgfp" [shape=rectangle, href="/experiments/2013-06-03_growgfp", fontsize=11, color="#cccccc", label="Grow sfGFP E. Coli", penwidth=2];
"/experiments/2014-01-02_restreak" [shape=rectangle, href="/experiments/2014-01-02_restreak", fontsize=11, color="#61BD4D", label="Restreak Plates", penwidth=2];
"/experiments/2013-06-25_induction4" [shape=rectangle, href="/experiments/2013-06-25_induction4", fontsize=11, color="#cccccc", label="more careful induction", penwidth=2];
"/experiments/2013-10-05_rnaextraction" [shape=rectangle, href="/experiments/2013-10-05_rnaextraction", fontsize=11, color="#cccccc", label="RNA extraction", penwidth=2];
"/experiments/2013-06-25_induction1" [shape=rectangle, href="/experiments/2013-06-25_induction1", fontsize=11, color="#cccccc", label="GFP induction timepoints", penwidth=2];
"/experiments/2013-06-25_induction3" [shape=rectangle, href="/experiments/2013-06-25_induction3", fontsize=11, color="#cccccc", label="GFP, YFP induction", penwidth=2];
"/experiments/2013-06-25_induction2" [shape=rectangle, href="/experiments/2013-06-25_induction2", fontsize=11, color="#cccccc", label="GFP, YFP Induction", penwidth=2];
"/experiments/2013-06-06_tophatcufflinks" [shape=rectangle, href="/experiments/2013-06-06_tophatcufflinks", fontsize=11, color="#61BD4D", label="Tophat + Cufflinks", penwidth=2];
"/experiments/2013-07-21_methods" [shape=rectangle, href="/experiments/2013-07-21_methods", fontsize=11, color="#cccccc", label="compare extraction methods", penwidth=2];
"/experiments/2013-07-xx_rnaprep" [shape=rectangle, href="/experiments/2013-07-xx_rnaprep", fontsize=11, color="#cccccc", label="RNA isolation prep", penwidth=2];
"/experiments/2013-12-29_depgraph" [shape=rectangle, href="/experiments/2013-12-29_depgraph", fontsize=11, color="#61BD4D", label="Organize metadata", penwidth=2];
"/experiments/2013-06-11_wt" [shape=rectangle, href="/experiments/2013-06-11_wt", fontsize=11, color="#cccccc", label="Grow induced WT", penwidth=2];
"/experiments/2013-08-06_directzol" [shape=rectangle, href="/experiments/2013-08-06_directzol", fontsize=11, color="#61BD4D", label="2nd try at DirectZol", penwidth=2];
"/experiments/2013-06-04_primers" [shape=rectangle, href="/experiments/2013-06-04_primers", fontsize=11, color="#cccccc", label="Check Primers", penwidth=2];
"/experiments/2013-06-04_break" [shape=rectangle, href="/experiments/2013-06-04_break", fontsize=11, color="#cccccc", label="Finals and \"Break\"", penwidth=2];
"/experiments/2013-06-04_overview" [shape=rectangle, href="/experiments/2013-06-04_overview", fontsize=11, color="#cccccc", label="CyanoTF Overview", penwidth=2];
"/experiments/2013-12-17_rnaextraction" [shape=rectangle, href="/experiments/2013-12-17_rnaextraction", fontsize=11, color="#cccccc", label="RNA extraction with varying amounts of TRI", penwidth=2];
"/experiments/2013-06-25_inductionprep" [shape=rectangle, href="/experiments/2013-06-25_inductionprep", fontsize=11, color="#cccccc", label="Induction Prep", penwidth=2];
"/experiments/2013-07-xx_pgtx" [shape=rectangle, href="/experiments/2013-07-xx_pgtx", fontsize=11, color="#cccccc", label="making PGTX", penwidth=2];
"/experiments/2013-06-13_cloning" [shape=rectangle, href="/experiments/2013-06-13_cloning", fontsize=11, color="#cccccc", label="Re-cloning TFs", penwidth=2];
"/experiments/2013-12-11_rnaextraction" [shape=rectangle, href="/experiments/2013-12-11_rnaextraction", fontsize=11, color="#cccccc", label="RNA extraction to test TRI:pellet ratios", penwidth=2];
"/experiments/2013-12-27_depgraph" [shape=rectangle, href="/experiments/2013-12-27_depgraph", fontsize=11, color="#cccccc", label="Working on the DepGraph plugin", penwidth=2];
"/experiments/2013-12-21_buildgitit" [shape=rectangle, href="/experiments/2013-12-21_buildgitit", fontsize=11, color="#cccccc", label="Building Gitit from Source", penwidth=2];
"/experiments/2013-06-11_stanley" [shape=rectangle, href="/experiments/2013-06-11_stanley", fontsize=11, color="#cccccc", label="Stanley Protocols", penwidth=2];
"/experiments/2013-06-24_bgfpc" [shape=rectangle, href="/experiments/2013-06-24_bgfpc", fontsize=11, color="#cccccc", label="100X BG-FPC Media", penwidth=2];
"/experiments/2013-07-10_losses" [shape=rectangle, href="/experiments/2013-07-10_losses", fontsize=11, color="#cccccc", label="taking stock of strains", penwidth=2];
"/experiments/2013-07-22_methods3" [shape=rectangle, href="/experiments/2013-07-22_methods3", fontsize=11, color="#cccccc", label="compare extraction quality", penwidth=2];
"/experiments/2013-06-04_bg11" -> "/experiments/2013-06-04_break"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-04_overview" -> "/experiments/2013-12-19_planmacro"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-07-xx_pgtx" -> "/experiments/2013-07-xx_rnaprep"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-07-xx_rnaprep" -> "/experiments/2013-07-21_methods"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-04_break" -> "/experiments/2013-06-03_growgfp"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-12_cloning" -> "/experiments/2013-06-13_cloning"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-04_break" -> "/experiments/2013-06-06_cloning"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-07-22_methods3" -> "/experiments/2013-08-06_directzol"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-25_induction2" -> "/experiments/2013-06-25_induction3"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-25_induction4" -> "/experiments/2013-07-01_fluoromax"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-11_wt" -> "/experiments/2013-06-25_inductionprep"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-04_overview" -> "/experiments/2013-12-21_buildgitit"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-04_overview" -> "/experiments/2013-06-04_break"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-07-21_methods" -> "/experiments/2013-07-22_methods3"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-12-17_rnaextraction" -> "/experiments/2014-01-02_startwt"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-25_induction1" -> "/experiments/2013-06-25_induction2"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-04_primers" -> "/experiments/2013-06-06_cloning"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-12-21_buildgitit" -> "/experiments/2013-12-27_depgraph"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-04_bg11" -> "/experiments/2013-06-24_bgfpc"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-12-11_rnaextraction" -> "/experiments/2013-12-15_rnaextraction"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-11_stanley" -> "/experiments/2013-06-13_chipseq"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-04_learning" -> "/experiments/2013-06-06_tophatcufflinks"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-04_break" -> "/experiments/2013-06-04_primers"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-12-27_depgraph" -> "/experiments/2013-12-29_depgraph"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-25_induction3" -> "/experiments/2013-06-25_induction4"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-06_cloning" -> "/experiments/2013-06-12_cloning"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-04_overview" -> "/experiments/2013-06-04_bg11"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-04_overview" -> "/experiments/2013-07-xx_pgtx"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-07-01_fluoromax" -> "/experiments/2013-07-xx_induction"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-10-05_rnaextraction" -> "/experiments/2013-12-11_rnaextraction"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-12-15_rnaextraction" -> "/experiments/2013-12-17_rnaextraction"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-07-10_losses" -> "/experiments/2013-06-21_cleaning"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-25_inductionprep" -> "/experiments/2013-06-25_induction1"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-21_cleaning" -> "/experiments/2014-01-02_restreak"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-04_overview" -> "/experiments/2013-06-04_learning"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-13_cloning" -> "/experiments/2013-07-10_losses"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-07-01_fluoromax" -> "/experiments/2013-09-27_iptgplates"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-03_growgfp" -> "/experiments/2013-06-11_wt"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-04_overview" -> "/experiments/2013-06-11_stanley"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-06-24_bgfpc" -> "/experiments/2013-06-25_inductionprep"  [color="#CCCCCC", fontsize=11, penwidth=2];
"/experiments/2013-07-21_methods" -> "/experiments/2013-10-05_rnaextraction"  [color="#CCCCCC", fontsize=11, penwidth=2];
}
Was it helpful?

Solution

You can use the "rank=same" approach:

strict digraph  {
{rank=same; 3; 4;}
    1 -> 2;
    1 -> 4;
    2 -> 3;
}

enter image description here

This pydot code produces the same image:

import pydot

node1 = pydot.Node(1)
node2 = pydot.Node(2)
node3 = pydot.Node(3)
node4 = pydot.Node(4)

P = pydot.Dot()
P.add_edge(pydot.Edge(node1,node2))
P.add_edge(pydot.Edge(node2,node3))
P.add_edge(pydot.Edge(node1,node4))

S = pydot.Subgraph(rank='same')
S.add_node(node3)
S.add_node(node4)
P.add_subgraph(S)
P.write('foo.dot')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top