[SciPy-user] gplt and xplt

John Hunter jdhunter at ace.bsd.uchicago.edu
Thu Aug 12 15:57:02 CDT 2004

>>>>> "David" == David M Cooke <cookedm at physics.mcmaster.ca> writes:

    David> [What I don't like about matplotlib, for instance, is its
    David> insistence on using matlab commands acting on a global plot
    David> instead of acting on plot objects (like biggles does).]

Not quite accurate - there is no insistence on this at all.  In
fairness, the matlab interface is by far the best documented, but
there is an OO API which you can use in a GUIs, in a script, or from
the shell.  The matlab interface is a very thin wrapper around this

Here is a simple "pythonic" example using matplotlib with no hidden
usage of global objects - more details at

    from matplotlib.matlab import figure, close, axes, subplot, show
    from matplotlib.numerix import arange, sin, pi

    t = arange(0.0, 1.0, 0.01)

    fig = figure(1)

    ax1 = fig.add_subplot(211)
    ax1.plot(t, sin(2*pi*t))
    ax1.set_ylim( (-2,2) )
    ax1.set_ylabel('1 Hz')
    ax1.set_title('A sine wave or two')

    for label in ax1.get_xticklabels():

    ax2 = fig.add_subplot(212)
    ax2.plot(t, sin(2*2*pi*t))
    ax2.set_ylim( (-2,2) )
    l = ax2.set_xlabel('Hi mom')


I actually prefer the matlab style interface because I find it much
more pithy, eg

    xlabel('Hi mom', color='g', fontsize='large')

but many people like you prefer the approach above and use matplotlib
that way.


More information about the SciPy-user mailing list