Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > media > contrib-backports > by-pkgid > a44f8c7e78ee9c5838c1fb080c9e7630 > files > 1088

python-matplotlib-doc-1.1.1-1mdv2010.1.noarch.rpm

.. _api-engineering_formatter:

api example code: engineering_formatter.py
==========================================



.. plot:: /home/mandrake/rpm/BUILD/matplotlib-1.1.1/doc/mpl_examples/api/engineering_formatter.py

::

    '''
    Demo to show use of the engineering Formatter.
    '''
    
    import matplotlib.pyplot as plt
    import numpy as np
    
    from matplotlib.ticker import EngFormatter
    
    ax = plt.subplot(111)
    ax.set_xscale('log')
    formatter = EngFormatter(unit='Hz', places=1)
    ax.xaxis.set_major_formatter(formatter)
    
    xs = np.logspace(1, 9, 100)
    ys = (0.8 + 0.4 * np.random.uniform(size=100)) * np.log10(xs)**2
    ax.plot(xs, ys)
    
    plt.show()
    

Keywords: python, matplotlib, pylab, example, codex (see :ref:`how-to-search-examples`)