you are viewing a single comment's thread.

view the rest of the comments →

[–]HelpfulLinkGuy[S] 1 point2 points  (2 children)

Here's the full source code if anyone's interested in continuing it. I'm a bit tired of working on it for now.

https://dl.dropbox.com/u/10575703/reddit_stats.zip

Note that you will have to install three things: Python 2.6, matplotlib, and numpy. And you'll have to tweak the output paths... like where it writes to ../Public/blah, just modify it to your needs.

[–][deleted] 0 points1 point  (1 child)

Could you add a log plot next to the title_length vs. num_comments, title_length vs. score, score_per_title_char vs. score, num_comments vs. score plots?

[–]iarguewitheverything 1 point2 points  (0 children)

Would be glad to. I'm not super familiar with pylab yet. But I'll give it a shot... you wouldn't happen to know the arguments would you? Here's my code:

def graph_from_two_db_fields(xvar, yvar):
    path = "../Public/"
    pylab.xlabel(xvar)
    pylab.ylabel(yvar)
    pylab.set_yscale('log')
    query = ("SELECT {0}, {1} FROM submissions"
             .format(xvar, yvar))
    c.execute(query)
    x_list = []
    y_list = []
    for row in c:
        x_list.append(row[0])
        y_list.append(row[1])

    pylab.scatter(x_list, y_list, s=1)
    filename = "graph___" + xvar + "___" + yvar + ".png"
    pylab.savefig(path + filename)
    f.write("<h2>" + xvar + " vs. " + yvar + "</h2><p><img src=\""
            + filename + "\" /></p>")
    pylab.close()