Sophie

Sophie

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

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



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Text introduction &mdash; Matplotlib v1.1.1 documentation</title>
    <link rel="stylesheet" href="../_static/mpl.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.1.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Matplotlib v1.1.1 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="top" title="Matplotlib v1.1.1 documentation" href="../index.html" />
    <link rel="up" title="Working with text" href="index_text.html" />
    <link rel="next" title="Text properties and layout" href="text_props.html" />
    <link rel="prev" title="Working with text" href="index_text.html" /> 
  </head>
  <body>
<!-- Piwik -->
<script type="text/javascript">
if ("matplotlib.sourceforge.net" == document.location.hostname ||
    "matplotlib.sf.net" == document.location.hostname) {
  var pkBaseURL = (("https:" == document.location.protocol) ? "https://apps.sourceforge.net/piwik/matplotlib/" : "http://apps.sourceforge.net/piwik/matplotlib/");
  document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
<script type="text/javascript">
if ("matplotlib.sourceforge.net" == document.location.hostname ||
    "matplotlib.sf.net" == document.location.hostname) {
  piwik_action_name = '';
  piwik_idsite = 1;
  piwik_url = pkBaseURL + "piwik.php";
  piwik_log(piwik_action_name, piwik_idsite, piwik_url);
  document.write(unescape('%3Cobject%3E%3Cnoscript%3E%3Cp%3E%3Cimg src="http://apps.sourceforge.net/piwik/matplotlib/piwik.php?idsite=1" alt="piwik"/%3E%3C/p%3E%3C/noscript%3E%3C/object%3E'));
}
</script>
<!-- End Piwik Tag -->
<link rel="shortcut icon" href="_static/favicon.ico">

<div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px">
<a href="../index.html"><img src="../_static/logo2.png" border="0" alt="matplotlib"/></a>
</div>

    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="text_props.html" title="Text properties and layout"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="index_text.html" title="Working with text"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">home</a>|&nbsp;</li>
        <li><a href="../search.html">search</a>|&nbsp;</li>
        <li><a href="../examples/index.html">examples</a>|&nbsp;</li>
        <li><a href="../gallery.html">gallery</a>|&nbsp;</li>
        <li><a href="../contents.html">docs</a> &raquo;</li>

          <li><a href="index.html" >User&#8217;s Guide</a> &raquo;</li>
          <li><a href="index_text.html" accesskey="U">Working with text</a> &raquo;</li> 
      </ul>
    </div>

      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Text introduction</a></li>
<li><a class="reference internal" href="#basic-text-commands">Basic text commands</a></li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="index_text.html"
                        title="previous chapter">Working with text</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="text_props.html"
                        title="next chapter">Text properties and layout</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/users/text_intro.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="text-introduction">
<span id="text-intro"></span><h1>Text introduction<a class="headerlink" href="#text-introduction" title="Permalink to this headline">¶</a></h1>
<p>matplotlib has excellent text support, including mathematical
expressions, truetype support for raster and vector outputs, newline
separated text with arbitrary rotations, and unicode support.  Because
we embed the fonts directly in the output documents, eg for postscript
or PDF, what you see on the screen is what you get in the hardcopy.
<a class="reference external" href="http://freetype.sourceforge.net/index2.html">freetype2</a> support
produces very nice, antialiased fonts, that look good even at small
raster sizes.  matplotlib includes its own
<a class="reference internal" href="../api/font_manager_api.html#module-matplotlib.font_manager" title="matplotlib.font_manager"><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.font_manager</span></tt></a>, thanks to Paul Barrett, which
implements a cross platform, W3C compliant font finding algorithm.</p>
<p>You have total control over every text property (font size, font
weight, text location and color, etc) with sensible defaults set in
the rc file.  And significantly for those interested in mathematical
or scientific figures, matplotlib implements a large number of TeX
math symbols and commands, to support <a class="reference internal" href="mathtext.html#mathtext-tutorial"><em>mathematical expressions</em></a> anywhere in your figure.</p>
</div>
<div class="section" id="basic-text-commands">
<h1>Basic text commands<a class="headerlink" href="#basic-text-commands" title="Permalink to this headline">¶</a></h1>
<p>The following commands are used to create text in the pyplot
interface</p>
<ul>
<li><p class="first"><a class="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.text" title="matplotlib.pyplot.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a> - add text at an arbitrary location to the <tt class="docutils literal"><span class="pre">Axes</span></tt>;
<a class="reference internal" href="../api/axes_api.html#matplotlib.axes.Axes.text" title="matplotlib.axes.Axes.text"><tt class="xref py py-meth docutils literal"><span class="pre">matplotlib.axes.Axes.text()</span></tt></a> in the API.</p>
</li>
<li><p class="first"><a class="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.xlabel" title="matplotlib.pyplot.xlabel"><tt class="xref py py-func docutils literal"><span class="pre">xlabel()</span></tt></a> - add an axis label to the x-axis;
<a class="reference internal" href="../api/axes_api.html#matplotlib.axes.Axes.set_xlabel" title="matplotlib.axes.Axes.set_xlabel"><tt class="xref py py-meth docutils literal"><span class="pre">matplotlib.axes.Axes.set_xlabel()</span></tt></a> in the API.</p>
</li>
<li><p class="first"><a class="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.ylabel" title="matplotlib.pyplot.ylabel"><tt class="xref py py-func docutils literal"><span class="pre">ylabel()</span></tt></a> - add an axis label to the y-axis;
<a class="reference internal" href="../api/axes_api.html#matplotlib.axes.Axes.set_ylabel" title="matplotlib.axes.Axes.set_ylabel"><tt class="xref py py-meth docutils literal"><span class="pre">matplotlib.axes.Axes.set_ylabel()</span></tt></a> in the API.</p>
</li>
<li><p class="first"><a class="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.title" title="matplotlib.pyplot.title"><tt class="xref py py-func docutils literal"><span class="pre">title()</span></tt></a> - add a title to the <tt class="docutils literal"><span class="pre">Axes</span></tt>;
<a class="reference internal" href="../api/axes_api.html#matplotlib.axes.Axes.set_title" title="matplotlib.axes.Axes.set_title"><tt class="xref py py-meth docutils literal"><span class="pre">matplotlib.axes.Axes.set_title()</span></tt></a> in the API.</p>
</li>
<li><p class="first"><a class="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.figtext" title="matplotlib.pyplot.figtext"><tt class="xref py py-func docutils literal"><span class="pre">figtext()</span></tt></a> - add text at an arbitrary location to the <tt class="docutils literal"><span class="pre">Figure</span></tt>;
<a class="reference internal" href="../api/figure_api.html#matplotlib.figure.Figure.text" title="matplotlib.figure.Figure.text"><tt class="xref py py-meth docutils literal"><span class="pre">matplotlib.figure.Figure.text()</span></tt></a> in the API.</p>
</li>
<li><p class="first"><a class="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.suptitle" title="matplotlib.pyplot.suptitle"><tt class="xref py py-func docutils literal"><span class="pre">suptitle()</span></tt></a> - add a title to the <tt class="docutils literal"><span class="pre">Figure</span></tt>;
<a class="reference internal" href="../api/figure_api.html#matplotlib.figure.Figure.suptitle" title="matplotlib.figure.Figure.suptitle"><tt class="xref py py-meth docutils literal"><span class="pre">matplotlib.figure.Figure.suptitle()</span></tt></a> in the API.</p>
</li>
<li><dl class="first docutils">
<dt><a class="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.annotate" title="matplotlib.pyplot.annotate"><tt class="xref py py-func docutils literal"><span class="pre">annotate()</span></tt></a> - add an annotation, with</dt>
<dd><p class="first last">optional arrow, to the <tt class="docutils literal"><span class="pre">Axes</span></tt> ; <a class="reference internal" href="../api/axes_api.html#matplotlib.axes.Axes.annotate" title="matplotlib.axes.Axes.annotate"><tt class="xref py py-meth docutils literal"><span class="pre">matplotlib.axes.Axes.annotate()</span></tt></a>
in the API.</p>
</dd>
</dl>
</li>
</ul>
<p>All of these functions create and return a
<a class="reference internal" href="../api/artist_api.html#matplotlib.text.Text" title="matplotlib.text.Text"><tt class="xref py py-func docutils literal"><span class="pre">matplotlib.text.Text()</span></tt></a> instance, which can bew configured with a
variety of font and other properties.  The example below shows all of
these commands in action.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># -*- coding: utf-8 -*-</span>
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="kn">as</span> <span class="nn">plt</span>

<span class="n">fig</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">()</span>
<span class="n">fig</span><span class="o">.</span><span class="n">suptitle</span><span class="p">(</span><span class="s">&#39;bold figure suptitle&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">14</span><span class="p">,</span> <span class="n">fontweight</span><span class="o">=</span><span class="s">&#39;bold&#39;</span><span class="p">)</span>

<span class="n">ax</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">add_subplot</span><span class="p">(</span><span class="mi">111</span><span class="p">)</span>
<span class="n">fig</span><span class="o">.</span><span class="n">subplots_adjust</span><span class="p">(</span><span class="n">top</span><span class="o">=</span><span class="mf">0.85</span><span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">set_title</span><span class="p">(</span><span class="s">&#39;axes title&#39;</span><span class="p">)</span>

<span class="n">ax</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s">&#39;xlabel&#39;</span><span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s">&#39;ylabel&#39;</span><span class="p">)</span>

<span class="n">ax</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="s">&#39;boxed italics text in data coords&#39;</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="s">&#39;italic&#39;</span><span class="p">,</span>
        <span class="n">bbox</span><span class="o">=</span><span class="p">{</span><span class="s">&#39;facecolor&#39;</span><span class="p">:</span><span class="s">&#39;red&#39;</span><span class="p">,</span> <span class="s">&#39;alpha&#39;</span><span class="p">:</span><span class="mf">0.5</span><span class="p">,</span> <span class="s">&#39;pad&#39;</span><span class="p">:</span><span class="mi">10</span><span class="p">})</span>

<span class="n">ax</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="s">r&#39;an equation: $E=mc^2$&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">15</span><span class="p">)</span>

<span class="n">ax</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="nb">unicode</span><span class="p">(</span><span class="s">&#39;unicode: Institut f</span><span class="se">\374</span><span class="s">r Festk</span><span class="se">\366</span><span class="s">rperphysik&#39;</span><span class="p">,</span> <span class="s">&#39;latin-1&#39;</span><span class="p">))</span>

<span class="n">ax</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="mf">0.95</span><span class="p">,</span> <span class="mf">0.01</span><span class="p">,</span> <span class="s">&#39;colored text in axes coords&#39;</span><span class="p">,</span>
        <span class="n">verticalalignment</span><span class="o">=</span><span class="s">&#39;bottom&#39;</span><span class="p">,</span> <span class="n">horizontalalignment</span><span class="o">=</span><span class="s">&#39;right&#39;</span><span class="p">,</span>
        <span class="n">transform</span><span class="o">=</span><span class="n">ax</span><span class="o">.</span><span class="n">transAxes</span><span class="p">,</span>
        <span class="n">color</span><span class="o">=</span><span class="s">&#39;green&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">15</span><span class="p">)</span>


<span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">([</span><span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="s">&#39;o&#39;</span><span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">annotate</span><span class="p">(</span><span class="s">&#39;annotate&#39;</span><span class="p">,</span> <span class="n">xy</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">xytext</span><span class="o">=</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span>
            <span class="n">arrowprops</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span><span class="n">facecolor</span><span class="o">=</span><span class="s">&#39;black&#39;</span><span class="p">,</span> <span class="n">shrink</span><span class="o">=</span><span class="mf">0.05</span><span class="p">))</span>

<span class="n">ax</span><span class="o">.</span><span class="n">axis</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">10</span><span class="p">])</span>

<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
<p>(<a class="reference external" href="../pyplots/text_commands.py">Source code</a>, <a class="reference external" href="../pyplots/text_commands.png">png</a>, <a class="reference external" href="../pyplots/text_commands.hires.png">hires.png</a>, <a class="reference external" href="../pyplots/text_commands.pdf">pdf</a>)</p>
<div class="figure">
<img alt="../_images/text_commands.png" src="../_images/text_commands.png" />
</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="text_props.html" title="Text properties and layout"
             >next</a> |</li>
        <li class="right" >
          <a href="index_text.html" title="Working with text"
             >previous</a> |</li>
        <li><a href="../index.html">home</a>|&nbsp;</li>
        <li><a href="../search.html">search</a>|&nbsp;</li>
        <li><a href="../examples/index.html">examples</a>|&nbsp;</li>
        <li><a href="../gallery.html">gallery</a>|&nbsp;</li>
        <li><a href="../contents.html">docs</a> &raquo;</li>

          <li><a href="index.html" >User&#8217;s Guide</a> &raquo;</li>
          <li><a href="index_text.html" >Working with text</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2008, John Hunter, Darren Dale, Michael Droettboom.
      Last updated on Oct 04, 2012.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
    </div>
  </body>
</html>