Sophie

Sophie

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

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

.. _api-mathtext_asarray:

api example code: mathtext_asarray.py
=====================================



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

::

    """
    Load a mathtext image as numpy array
    """
    
    import numpy as np
    import matplotlib.mathtext as mathtext
    import matplotlib.pyplot as plt
    import matplotlib
    matplotlib.rc('image', origin='upper')
    
    parser = mathtext.MathTextParser("Bitmap")
    
    
    parser.to_png('test2.png', r'$\left[\left\lfloor\frac{5}{\frac{\left(3\right)}{4}} y\right)\right]$', color='green', fontsize=14, dpi=100)
    
    
    rgba1, depth1 = parser.to_rgba(r'IQ: $\sigma_i=15$', color='blue', fontsize=20, dpi=200)
    rgba2, depth2 = parser.to_rgba(r'some other string', color='red', fontsize=20, dpi=200)
    
    fig = plt.figure()
    fig.figimage(rgba1.astype(float)/255., 100, 100)
    fig.figimage(rgba2.astype(float)/255., 100, 300)
    
    plt.show()
    

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