Ask Your Question

Revision history [back]

Hi,

Imho it's easier to write a few lines of code to plot graphs unsing plotting primitives, something like code below. S denotes my graph (a simple dictionary, for each key u, S[u] is the list of neighbours), xy is a dictionary which indicates positions of vertices, defined elsewhere as ms (vertex size) and fs (font size).

    G = Graphics()
    p = [xy[u] for u in S]
    c = [my_color(u) for u in S]
    G += scatter_plot (p, markersize = ms, facecolor = c, **kwds)
    for u in S:
        for v in S[u]:
            G += line ([xy[u], xy[v]])
    G += sum (text (my_str(u), xy[u], fontsize = fs, zorder = 10) for u in S)

It's that simple, and anything (position, size, color of vertices, font size, text to display for each vertex) is under control.

Hi,

Imho it's easier to write a few lines of code to plot graphs unsing plotting primitives, something like code below. S denotes my graph (a simple dictionary, for each key u, S[u] is the list of neighbours), xy is a dictionary which indicates positions of vertices, defined elsewhere as ms (vertex size) and fs (font size).

    G = Graphics()
    p = [xy[u] for u in S]
    c = [my_color(u) for u in S]
    G += scatter_plot (p, markersize = ms, facecolor = c, **kwds)
    for u in S:
        for v in S[u]:
            G += line ([xy[u], xy[v]])
    G += sum (text (my_str(u), xy[u], fontsize = fs, zorder = 10) for u in S)

It's that simple, and anything (position, size, color of vertices, font size, text to display for each vertex) is under control.

Imho it's easier to write a few lines of code to plot graphs unsing plotting primitives, something like code below. S denotes my graph (a simple dictionary, for each key u, S[u] is the list of neighbours), xy is a dictionary which indicates positions of vertices, defined elsewhere as are ms (vertex size) and fs (font size).

    G = Graphics()
    p = [xy[u] for u in S]
    c = [my_color(u) for u in S]
    G += scatter_plot (p, markersize = ms, facecolor = c, **kwds)
    for u in S:
        for v in S[u]:
            G += line ([xy[u], xy[v]])
    G += sum (text (my_str(u), xy[u], fontsize = fs, zorder = 10) for u in S)

It's that simple, and anything (position, size, color of vertices, font size, text to display for each vertex) is under control.

Imho it's easier to write a few lines of code to plot graphs unsing using plotting primitives, something like code below. S denotes my graph (a simple dictionary, for each key u, S[u] is the list of neighbours), xy is a dictionary which indicates positions of vertices, defined elsewhere as are ms (vertex size) and fs (font size).

    G = Graphics()
    p = [xy[u] for u in S]
    c = [my_color(u) for u in S]
    G += scatter_plot (p, markersize = ms, facecolor = c, **kwds)
    for u in S:
        for v in S[u]:
            G += line ([xy[u], xy[v]])
    G += sum (text (my_str(u), xy[u], fontsize = fs, zorder = 10) for u in S)

It's that simple, and anything (position, size, color of vertices, font size, text to display for each vertex) is under control.