예제 #1
0
 def plot(self):
     "Function to plot a debruijn graph"
     e0 = [i[0] for i in self.edges]
     e1 = [i[1] for i in self.edges]
     self.plot = plot
     toyplot.graph(e0, e1, tmarker=">", vlstyle={'font-size': '8px'})
     return self.plot
예제 #2
0
    def plot(self):
        """Plots the graph."""
        parents, children = zip(*self.edges())
        singletons = [
            i for i in range(self.num_vertices()) if self.degree(i) == 0
        ]
        parent_names = list(map(self.vertex_label, parents))
        child_names = list(map(self.vertex_label, children))
        singleton_names = list(map(self.vertex_label, singletons))

        canvas, axes, mark = toyplot.graph(parent_names,
                                           child_names,
                                           singleton_names,
                                           ecolor="black",
                                           tmarker=">",
                                           vcolor="white",
                                           vmarker="o",
                                           vsize=80,
                                           vstyle={"stroke": "black"})
        # keep vertices from falling outside of the canvas
        axes.padding = 50
예제 #3
0
def plot_vertexes(x, y, n, edges_plot):
    coordinates = np.transpose(np.vstack((x, y)))
    layout = toyplot.layout.FruchtermanReingold()
    vstyle = {"stroke": toyplot.color.black}
    vlstyle = {"fill": "white"}
    colormap = toyplot.color.LinearMap(toyplot.color.Palette(
        ["white"]))  #, "yellow", "red"]))
    canvas, axes, mark = toyplot.graph(
        edges_plot,  #extra_vertices ,
        vcoordinates=coordinates,
        layout=layout,
        vcolor=colormap,
        vsize=30,
        vstyle=vstyle,
        width=10000)
    axes.show = True
    axes.aspect = None
    axes.y.show = False
    axes.x.show = False

    toyplot.pdf.render(canvas, "nodes.pdf")
예제 #4
0
 def plot(self):
     "This function return a toyplot graph"
     e0 = [i[0] for i in self.edges]
     e1 = [i[1] for i in self.edges]
     toyplot.graph(e0, e1, tmarker=">", vlstyle={'font-size': '8px'});
예제 #5
0
 def plot(self):
     e0 = [i[0] for i in self.edges]
     e1 = [i[1] for i in self.edges]
     toyplot.graph(e0, e1, tmarker=">", vlstyle={'font-size': '8px'})
예제 #6
0
    #
    # node_df = pd.DataFrame(node_data)
    # edge_df = pd.DataFrame(edge_data)
    #
    # node_df.to_csv('node.csv', index=False)
    # edge_df.to_csv('edge.csv', index=False)

    edges = []

    for u, v, meta in G.edges(data=True):
        if meta['back_edge']:
            continue

        verbs = list(meta['verbs'])
        is_sub = len(verbs) == 1 and verbs[0] == 'subset'
        dead_end = G.degree[u] <= 2 and is_sub
        if dead_end:
            continue

        u_head = G.nodes[u]['head']
        v_head = G.nodes[v]['head']

        edge = [format_text(u_head), format_text(v_head)]
        edges.append(edge)

    canvas, axes, mark = toyplot.graph(np.array(edges),
                                       vsize=30,
                                       width=5000,
                                       height=5000)
    to_pdf.render(canvas, 'figure1.pdf')
예제 #7
0
tedges = []
for i in range(0, len(offset) - 1):
    start = offset[i]
    end = offset[i + 1]
    if start == end:
        extra_nodes.append(i)
    while start < end:
        l = [i, edges[start]]
        tedges.append(l)
        start += 1

vcoordinates = np.ma.masked_all((len(offset), 2))
for i in range(0, len(offset)):
    vcoordinates[i] = (xy[i][0], xy[i][1])

colormap = toyplot.color.LinearMap(
    toyplot.color.Palette(["white", "yellow", "red"]))
vstyle = {"stroke": toyplot.color.black}

tedges = np.array(tedges)
layout = toyplot.layout.FruchtermanReingold()
c, y, z = toyplot.graph(tedges,
                        extra_nodes,
                        vcoordinates=vcoordinates,
                        width=600)  #,vcolor=colormap, vsize=5, vstyle=vstyle)
# toyplot.png.render(c, "figure1.png")
toyplot.pdf.render(c, "figure1.pdf")

c1, y1, z1 = toyplot.graph(
    tedges, width=600)  #,vcolor=colormap, vsize=5, vstyle=vstyle)
toyplot.pdf.render(c1, "figure2.pdf")