newbie graphing recommendations ?

John Hunter jdhunter at ace.bsd.uchicago.edu
Mon Jul 17 09:45:37 EDT 2006


>>>>> "bearophileHUGS" == bearophileHUGS  <bearophileHUGS at lycos.com> writes:

    bearophileHUGS> I think MatPlotLib can do this too, if your
    bearophileHUGS> computer is fast enough.

    >> i would also like to have the bars and graphs have nice shading
    >> if possible to give it a really attractive look.

    bearophileHUGS> Remember what Edward Tufte (www.edwardtufte.com)
    bearophileHUGS> says, often too much elaborations makes graphs
    bearophileHUGS> them less than useless.

I share Tufte's opinion that you should avoid chart-junk -- stuff
designed to make charts look sexier that don't add information
context.  matplotlib can do it (but doesn't go out of it's way to make
it easy).  Eg,

from pylab import figure, show, nx, cm

def gbar(ax, x, y, width=0.5, bottom=0):
    X = [[.6, .6],[.7,.7]]
    for left,top in zip(x, y):
        right = left+width
        ax.imshow(X, interpolation='bicubic', cmap=cm.Blues,
                  extent=(left, right, bottom, top), alpha=1)

fig = figure()

xmin, xmax = xlim = 0,10
ymin, ymax = ylim = 0,1
ax = fig.add_subplot(111, xlim=xlim, ylim=ylim,
                     autoscale_on=False)
X = [[.6, .6],[.7,.7]]

ax.imshow(X, interpolation='bicubic', cmap=cm.copper,
          extent=(xmin, xmax, ymin, ymax), alpha=1)

N = 10
x = nx.arange(N)+0.25
y = nx.mlab.rand(N)
gbar(ax, x, y, width=0.7)
ax.set_aspect('normal')
show()



More information about the Python-list mailing list