From Rizzo_Lab
Revision as of 15:03, 12 February 2010 by Sudipto (talk | contribs)
(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

This is combination of python, numpy and matplotlib which supposedly can do everything matlab can. We are still investigating this package to see if we can use directly for analysis scripts. This way be will not have to write python scripts that produce csv files for analysis in matlab.

Bar charts

import numpy.numarray as na
from pylab import *

labels = ["Baseline", "System"]
data =   [3.75               , 4.75]
error =  [0.3497             , 0.3108]

xlocations = na.array(range(len(data)))+0.5
width = 0.5
bar(xlocations, data, yerr=error, width=width)
yticks(range(0, 8))
xticks(xlocations+ width/2, labels)
xlim(0, xlocations[-1]+width*2)
title("Average Ratings on the Training Set")

Plotting a histogram

from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import FigureCanvasAgg
from pylab import randn 

x = randn(10000)
fig = Figure(figsize=(10,10))
ax = fig.add_subplot(111)
ax.set_xlabel("Random Numbers")
canvas = FigureCanvasAgg(fig)
canvas.print_figure("hist.png", dpi=300)