|
From: <jd...@us...> - 2009-08-06 14:56:02
|
Revision: 7400
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7400&view=rev
Author: jdh2358
Date: 2009-08-06 14:55:54 +0000 (Thu, 06 Aug 2009)
Log Message:
-----------
update whats new
Modified Paths:
--------------
branches/v0_99_maint/doc/users/whats_new.rst
Added Paths:
-----------
branches/v0_99_maint/doc/pyplots/whats_new_99_axes_grid.py
branches/v0_99_maint/doc/pyplots/whats_new_99_mplot3d.py
branches/v0_99_maint/doc/pyplots/whats_new_99_spines.py
Added: branches/v0_99_maint/doc/pyplots/whats_new_99_axes_grid.py
===================================================================
--- branches/v0_99_maint/doc/pyplots/whats_new_99_axes_grid.py (rev 0)
+++ branches/v0_99_maint/doc/pyplots/whats_new_99_axes_grid.py 2009-08-06 14:55:54 UTC (rev 7400)
@@ -0,0 +1,47 @@
+import numpy as np
+import matplotlib.pyplot as plt
+from mpl_toolkits.axes_grid.axes_rgb import RGBAxes
+
+def get_demo_image():
+ # prepare image
+ delta = 0.5
+
+ extent = (-3,4,-4,3)
+ x = np.arange(-3.0, 4.001, delta)
+ y = np.arange(-4.0, 3.001, delta)
+ X, Y = np.meshgrid(x, y)
+ import matplotlib.mlab as mlab
+ Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
+ Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
+ Z = (Z1 - Z2) * 10
+
+ return Z, extent
+
+
+
+def get_rgb():
+ Z, extent = get_demo_image()
+
+ Z[Z<0] = 0.
+ Z = Z/Z.max()
+
+ R = Z[:13,:13]
+ G = Z[2:,2:]
+ B = Z[:13,2:]
+
+ return R, G, B
+
+
+fig = plt.figure(1)
+ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])
+
+r, g, b = get_rgb()
+kwargs = dict(origin="lower", interpolation="nearest")
+ax.imshow_rgb(r, g, b, **kwargs)
+
+ax.RGB.set_xlim(0., 9.5)
+ax.RGB.set_ylim(0.9, 10.6)
+
+
+plt.draw()
+plt.show()
Added: branches/v0_99_maint/doc/pyplots/whats_new_99_mplot3d.py
===================================================================
--- branches/v0_99_maint/doc/pyplots/whats_new_99_mplot3d.py (rev 0)
+++ branches/v0_99_maint/doc/pyplots/whats_new_99_mplot3d.py 2009-08-06 14:55:54 UTC (rev 7400)
@@ -0,0 +1,17 @@
+from mpl_toolkits.mplot3d import Axes3D
+from matplotlib import cm
+import pylab
+import random
+import numpy as np
+
+fig = pylab.figure()
+ax = Axes3D(fig)
+X = np.arange(-5, 5, 0.25)
+Y = np.arange(-5, 5, 0.25)
+X, Y = np.meshgrid(X, Y)
+R = np.sqrt(X**2 + Y**2)
+Z = np.sin(R)
+ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)
+
+pylab.show()
+
Added: branches/v0_99_maint/doc/pyplots/whats_new_99_spines.py
===================================================================
--- branches/v0_99_maint/doc/pyplots/whats_new_99_spines.py (rev 0)
+++ branches/v0_99_maint/doc/pyplots/whats_new_99_spines.py 2009-08-06 14:55:54 UTC (rev 7400)
@@ -0,0 +1,47 @@
+import matplotlib.pyplot as plt
+import numpy as np
+from matplotlib.pyplot import show
+
+
+def adjust_spines(ax,spines):
+ for loc, spine in ax.spines.iteritems():
+ if loc in spines:
+ spine.set_position(('outward',10)) # outward by 10 points
+ else:
+ spine.set_color('none') # don't draw spine
+
+ # turn off ticks where there is no spine
+ if 'left' in spines:
+ ax.yaxis.set_ticks_position('left')
+ else:
+ # no yaxis ticks
+ ax.yaxis.set_ticks([])
+
+ if 'bottom' in spines:
+ ax.xaxis.set_ticks_position('bottom')
+ else:
+ # no xaxis ticks
+ ax.xaxis.set_ticks([])
+
+fig = plt.figure()
+
+x = np.linspace(0,2*np.pi,100)
+y = 2*np.sin(x)
+
+ax = fig.add_subplot(2,2,1)
+ax.plot(x,y)
+adjust_spines(ax,['left'])
+
+ax = fig.add_subplot(2,2,2)
+ax.plot(x,y)
+adjust_spines(ax,[])
+
+ax = fig.add_subplot(2,2,3)
+ax.plot(x,y)
+adjust_spines(ax,['left','bottom'])
+
+ax = fig.add_subplot(2,2,4)
+ax.plot(x,y)
+adjust_spines(ax,['bottom'])
+
+show()
Modified: branches/v0_99_maint/doc/users/whats_new.rst
===================================================================
--- branches/v0_99_maint/doc/users/whats_new.rst 2009-08-06 12:29:07 UTC (rev 7399)
+++ branches/v0_99_maint/doc/users/whats_new.rst 2009-08-06 14:55:54 UTC (rev 7400)
@@ -6,23 +6,57 @@
.. _whats-new-svn:
-What new in svn
-===============
+What new in matplotlib-0.99
+=============================
+.. _whats-new-mplot3d:
+
+mplot3d
+--------
+
+
+Reinier Heeres has ported John Porter's mplot3d over to the new
+matplotlib transformations framework, and it is now available as a
+toolkit mpl_toolkits.mplot3d. See the `examples
+<http://matplotlib.sourceforge.net/examples/mplot3d/index.html>`_ and
+:ref:`toolkit_mplot3d-tutorial`
+
+.. plot:: pyplots/whats_new_mplot3d.py
+
+.. _whats-new-axes-grid:
+
+axes grid toolkit
+-----------------
+
+Jae Joon has added a new toolkit to ease displaying multiple images in
+matplotlib, as well as some support for curvilinear grids to support
+the world coordinate system. See :ref:`axes_grid_users-guide-index`
+and `examples <http://matplotlib.sourceforge.net/examples/axes_grid/index.html>`_
+
+.. plot:: pyplots/whats_new_axes_grid.py
+
+.. _whats-new-spine:
+
Axis spine placement
--------------------
Andrew Straw has added the ability to place "axis spines" -- the lines
-that denote the data limits -- in various arbitrary locations. See
+that denote the data limits -- in various arbitrary locations. No
+longer are your axis lines constrained to be a simple rectangle around
+the figure -- you can turn on or off left, bottom, right and top, as
+well as "detach" the spine to offset it away from the data. See
+:ref:`pylab_examples-spine_placement_demo` and
:class:`matplotlib.spines.Spine`.
+.. plot:: pyplots/whats_new_99_spines.py
+
.. _whats-new-0-98-4:
What new in 0.98.4
==============================
It's been four months since the last matplotlib release, and there are
-a lot of new features and bug-fixes.
+a lot of new features and bug-fixes.
Thanks to Charlie Moad for testing and preparing the source release,
including binaries for OS X and Windows for python 2.4 and 2.5 (2.6
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-08-06 16:41:30
|
Revision: 7404
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7404&view=rev
Author: jdh2358
Date: 2009-08-06 16:41:18 +0000 (Thu, 06 Aug 2009)
Log Message:
-----------
some updates to site docs for release
Modified Paths:
--------------
branches/v0_99_maint/doc/_templates/index.html
branches/v0_99_maint/doc/_templates/indexsidebar.html
branches/v0_99_maint/doc/faq/installing_faq.rst
branches/v0_99_maint/doc/users/annotations.rst
branches/v0_99_maint/doc/users/plotting.rst
branches/v0_99_maint/doc/users/whats_new.rst
Modified: branches/v0_99_maint/doc/_templates/index.html
===================================================================
--- branches/v0_99_maint/doc/_templates/index.html 2009-08-06 16:11:30 UTC (rev 7403)
+++ branches/v0_99_maint/doc/_templates/index.html 2009-08-06 16:41:18 UTC (rev 7404)
@@ -1,9 +1,9 @@
{% extends "layout.html" %}
{% set title = 'matplotlib: python plotting' %}
-
+
{% block body %}
- <h1>mpl</h1>
+ <h1>intro</h1>
<p>matplotlib is a python 2D plotting library which produces
publication quality figures in a variety of hardcopy formats and
@@ -41,7 +41,7 @@
<a href="http://scipy.org/Numpy_Example_List_With_Doc">numpy</a> and
<a href="api/mlab_api.html">matplotlib.mlab</a>.</p>
- <h3>Plotting commands</h3> <br/>
+ <h3>plotting commands</h3> <br/>
<table border="1" cellpadding="3" cellspacing="2">
Modified: branches/v0_99_maint/doc/_templates/indexsidebar.html
===================================================================
--- branches/v0_99_maint/doc/_templates/indexsidebar.html 2009-08-06 16:11:30 UTC (rev 7403)
+++ branches/v0_99_maint/doc/_templates/indexsidebar.html 2009-08-06 16:41:18 UTC (rev 7404)
@@ -2,33 +2,26 @@
<p>Please <a href="http://sourceforge.net/project/project_donations.php?group_id=80706">donate</a>
to support matplotlib development.</p>
-
-<p> Download <a href="https://sourceforge.net/projects/matplotlib/">matplotlib-0.99.0</a>, see <a href="http://matplotlib.sourceforge.net/users/whats_new.html">what's
-new</a> and post any bugs to the <a href="http://sourceforge.net/tracker2/?group_id=80706">tracker</a>
+
+<p>matplotlib 0.99 is available for <a href="http://sourceforge.net/projects/matplotlib">download</a>. See <a href="{{ pathto('users/whats_new') }}">what's new</a> and tips on <a href="{{
+pathto('users/installing') }}">installing</a>
</p>
<p>Watch a <a href="http://videolectures.net/mloss08_hunter_mat">video lecture</a> about matplotlib presented at <a href="http://videolectures.net/mloss08_whistler">NIPS 08 Workshop</a> <i>Machine Learning Open Source Software</i></a>.
</p>
-<h3>Download</h3>
-<p>Current version: <b>{{ version }}</b></p>
-
-
-<p>Download matplotlib from the
-sourceforge <a href="http://sourceforge.net/projects/matplotlib">project</a>
-page (but first take a look at the <a href="{{
-pathto('users/installing') }}">installing</a> page). Here's a summary
-of <a href="{{ pathto('users/whats_new') }}">what's new</a>. </p>
-
<p>There are several matplotlib addon <a href="{{
pathto('users/toolkits') }}">toolkits</a>, including the projection
and mapping toolkit
-<a href="http://matplotlib.sf.net/basemap/doc/html">basemap</a>.</p>
+<a href="http://matplotlib.sf.net/basemap/doc/html">basemap</a>, 3d plotting with <a href="{{
+pathto('mpl_toolkits/mplot3d/index') }}">mplot3d</a>, wild and wonderful axes and axis helpers in <a href="{{
+pathto('mpl_toolkits/axes_grid/index') }}">axes_grid</a> and more.
+ </p>
<h3>Need help?</h3>
-<p>Check the <a href="{{ pathto('users/index') }}">user</a> guide,
+<p>Check the <a href="{{ pathto('users/index') }}">user guide</a>,
the <a href="{{ pathto('faq/index') }}">faq</a>, the <a href="{{
pathto('api/index') }}">api</a> docs,
<a href="http://www.nabble.com/matplotlib---users-f2906.html">archives</a>,
Modified: branches/v0_99_maint/doc/faq/installing_faq.rst
===================================================================
--- branches/v0_99_maint/doc/faq/installing_faq.rst 2009-08-06 16:11:30 UTC (rev 7403)
+++ branches/v0_99_maint/doc/faq/installing_faq.rst 2009-08-06 16:41:18 UTC (rev 7404)
@@ -293,23 +293,21 @@
-----------------------
If you want to install matplotlib from one of the binary installers we
-build, you have two choices: a mpkg installer, which is a typical
+build, you have two choices: a dmg installer, which is a typical
Installer.app, or an binary OSX egg, which you can install via
setuptools easy_install.
+
+The mkpg installer will have a "dmg" extension, and will have a name
+like :file:`matplotlib-0.99.0-py2.5-macosx10.5.dmg` depending on the
+python, matplotlib, and OSX versions. Save this file and double
+click it, which will open up a folder with a file in it that has the
+mpkg extension. Double click this to run the Installer.app, which
+will prompt you for a password if you need system wide installation
+privileges, and install to a directory like
+:file:`/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages`,
+again depedending on your python version. This directory should be in
+your python path, so you can test your installation with::
-The mkpg installer will have a "zip" extension, and will have a name
-like file:`matplotlib-0.99.0.rc1-py2.5-macosx10.5_mpkg.zip` depending on
-the python, matplotlib, and OSX versions. You need to unzip this file
-using either the "unzip" command on OSX, or simply double clicking on
-it to run StuffIt Expander. When you double click on the resultant
-mpkd directory, which will have a name like
-file:`matplotlib-0.99.0.rc1-py2.5-macosx10.5.mpkg`, it will run the
-Installer.app, prompt you for a password if you need system wide
-installation privileges, and install to a directory like
-file:`/Library/Python/2.5/site-packages/`, again depedending on your
-python version. This directory may not be in your python path, so you
-can test your installation with::
-
> python -c 'import matplotlib; print matplotlib.__version__, matplotlib.__file__'
If you get an error like::
@@ -320,9 +318,9 @@
then you will need to set your PYTHONPATH, eg::
- export PYTHONPATH=/Library/Python/2.5/site-packages:$PYTHONPATH
+ export PYTHONPATH=/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages:$PYTHONPATH
-See also ref:`environment-variables`.
+See also :ref:`environment-variables`.
.. _easy-install-osx-egg:
Modified: branches/v0_99_maint/doc/users/annotations.rst
===================================================================
--- branches/v0_99_maint/doc/users/annotations.rst 2009-08-06 16:11:30 UTC (rev 7403)
+++ branches/v0_99_maint/doc/users/annotations.rst 2009-08-06 16:41:18 UTC (rev 7404)
@@ -3,6 +3,9 @@
Annotating text
===============
+For a more detailed introduction to annotations, see
+:ref:`plotting-guide-annotation`.
+
The uses of the basic :func:`~matplotlib.pyplot.text` command above
place text at an arbitrary position on the Axes. A common use case of
text is to annotate some feature of the plot, and the
Modified: branches/v0_99_maint/doc/users/plotting.rst
===================================================================
--- branches/v0_99_maint/doc/users/plotting.rst 2009-08-06 16:11:30 UTC (rev 7403)
+++ branches/v0_99_maint/doc/users/plotting.rst 2009-08-06 16:41:18 UTC (rev 7404)
@@ -152,5 +152,4 @@
:ref:`plotting-guide-annotation`
-TODO; see :ref:`how-to-contribute-docs`.
Modified: branches/v0_99_maint/doc/users/whats_new.rst
===================================================================
--- branches/v0_99_maint/doc/users/whats_new.rst 2009-08-06 16:11:30 UTC (rev 7403)
+++ branches/v0_99_maint/doc/users/whats_new.rst 2009-08-06 16:41:18 UTC (rev 7404)
@@ -1,13 +1,14 @@
.. _whats-new:
-***************************
+************************
What's new in matplotlib
-***************************
+************************
-.. _whats-new-svn:
+This page just covers the highlights -- for the full story, see the
+`CHANGELOG <http://matplotlib.sourceforge.net/_static/CHANGELOG>`_
-What new in matplotlib-0.99
-=============================
+new in matplotlib-0.99
+======================
.. _whats-new-mplot3d:
@@ -50,10 +51,17 @@
.. plot:: pyplots/whats_new_99_spines.py
+
+New documentation
+-----------------
+
+jae-Joon Lee has written two new guides :ref:`plotting-guide-legend`
+and :ref:`plotting-guide-annotation`.
+
.. _whats-new-0-98-4:
-What new in 0.98.4
-==============================
+new in 0.98.4
+=============
It's been four months since the last matplotlib release, and there are
a lot of new features and bug-fixes.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-08-18 03:48:27
|
Revision: 7498
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7498&view=rev
Author: jdh2358
Date: 2009-08-18 03:48:21 +0000 (Tue, 18 Aug 2009)
Log Message:
-----------
added path tut
Modified Paths:
--------------
branches/v0_99_maint/doc/users/index.rst
Added Paths:
-----------
branches/v0_99_maint/doc/pyplots/compound_path_demo.py
branches/v0_99_maint/doc/users/path_tutorial.rst
Added: branches/v0_99_maint/doc/pyplots/compound_path_demo.py
===================================================================
--- branches/v0_99_maint/doc/pyplots/compound_path_demo.py (rev 0)
+++ branches/v0_99_maint/doc/pyplots/compound_path_demo.py 2009-08-18 03:48:21 UTC (rev 7498)
@@ -0,0 +1,42 @@
+import numpy as np
+
+import matplotlib.pyplot as plt
+import matplotlib.patches as patches
+import matplotlib.path as path
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+
+# histogram our data with numpy
+data = np.random.randn(1000)
+n, bins = np.histogram(data, 100)
+
+# get the corners of the rectangles for the histogram
+left = np.array(bins[:-1])
+right = np.array(bins[1:])
+bottom = np.zeros(len(left))
+top = bottom + n
+nrects = len(left)
+
+nverts = nrects*(1+3+1)
+verts = np.zeros((nverts, 2))
+codes = np.ones(nverts, int) * path.Path.LINETO
+codes[0::5] = path.Path.MOVETO
+codes[4::5] = path.Path.CLOSEPOLY
+verts[0::5,0] = left
+verts[0::5,1] = bottom
+verts[1::5,0] = left
+verts[1::5,1] = top
+verts[2::5,0] = right
+verts[2::5,1] = top
+verts[3::5,0] = right
+verts[3::5,1] = bottom
+
+barpath = path.Path(verts, codes)
+patch = patches.PathPatch(barpath, facecolor='green', edgecolor='yellow', alpha=0.5)
+ax.add_patch(patch)
+
+ax.set_xlim(left[0], right[-1])
+ax.set_ylim(bottom.min(), top.max())
+
+plt.show()
Modified: branches/v0_99_maint/doc/users/index.rst
===================================================================
--- branches/v0_99_maint/doc/users/index.rst 2009-08-18 02:41:43 UTC (rev 7497)
+++ branches/v0_99_maint/doc/users/index.rst 2009-08-18 03:48:21 UTC (rev 7498)
@@ -25,6 +25,7 @@
annotations_guide.rst
legend.rst
transforms_tutorial.rst
+ path_tutorial.rst
toolkits.rst
screenshots.rst
whats_new.rst
Added: branches/v0_99_maint/doc/users/path_tutorial.rst
===================================================================
--- branches/v0_99_maint/doc/users/path_tutorial.rst (rev 0)
+++ branches/v0_99_maint/doc/users/path_tutorial.rst 2009-08-18 03:48:21 UTC (rev 7498)
@@ -0,0 +1,187 @@
+.. _path_tutorial:
+
+*************
+Path Tutorial
+*************
+
+The object underlying all of the :mod:`matplotlib.patch` objects is
+the :class:`~matplotlib.path.Path`, which supports the standard set of
+moveto, lineto, curveto commands to draw simple and compoud outlines
+consisting of line segments and splines. The ``Path`` is instantiated
+with a (N,2) array of (x,y) vertices, and a N length array of path
+codes. For example to draw the unit rectangle from (0,0) to (1,1), we
+could use this code
+
+.. plot::
+ :include-source:
+
+ import matplotlib.pyplot as plt
+ from matplotlib.path import Path
+ import matplotlib.patches as patches
+
+ verts = [
+ (0., 0.), # left, bottom
+ (0., 1.), # left, top
+ (1., 1.), # right, top
+ (1., 0.), # right, bottom
+ (0., 0.), # ignored
+ ]
+
+ codes = [Path.MOVETO,
+ Path.LINETO,
+ Path.LINETO,
+ Path.LINETO,
+ Path.CLOSEPOLY,
+ ]
+
+ path = Path(verts, codes)
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ patch = patches.PathPatch(path, facecolor='orange', lw=2)
+ ax.add_patch(patch)
+ ax.set_xlim(-2,2)
+ ax.set_ylim(-2,2)
+ plt.show()
+
+
+The following path codes are recognized
+
+============== ================================= ====================================================================================================================
+Code Vertices Description
+============== ================================= ====================================================================================================================
+``STOP`` 1 (ignored) A marker for the end of the entire path (currently not required and ignored)
+``MOVETO`` 1 Pick up the pen and move to the given vertex.
+``LINETO`` 1 Draw a line from the current position to the given vertex.
+``CURVE3`` 2 (1 control point, 1 endpoint) Draw a quadratic Bezier curve from the current position, with the given control point, to the given end point.
+``CURVE4`` 3 (2 control points, 1 endpoint) Draw a cubic Bezier curve from the current position, with the given control points, to the given end point.
+``CLOSEPOLY`` 1 (ignored) Draw a line segment to the start point of the current polyline.
+============== ================================= ====================================================================================================================
+
+
+.. path-curves:
+
+
+Bezier example
+==============
+
+Some of the path components require multiple vertices to specify them:
+for example CURVE 3 is a `bezier
+<http://en.wikipedia.org/wiki/B%C3%A9zier_curve>`_ curve with one
+control point and one end point, and CURVE4 has three vertices for the
+two control points and the end point. The example below shows a
+CURVE4 Bezier spline -- the bezier curve will be contained in the
+convex hul of the start point, the two control points, and the end
+point
+
+.. plot::
+ :include-source:
+
+ import matplotlib.pyplot as plt
+ from matplotlib.path import Path
+ import matplotlib.patches as patches
+
+ verts = [
+ (0., 0.), # P0
+ (0.2, 1.), # P1
+ (1., 0.8), # P2
+ (0.8, 0.), # P3
+ ]
+
+ codes = [Path.MOVETO,
+ Path.CURVE4,
+ Path.CURVE4,
+ Path.CURVE4,
+ ]
+
+ path = Path(verts, codes)
+
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ patch = patches.PathPatch(path, facecolor='none', lw=2)
+ ax.add_patch(patch)
+
+ xs, ys = zip(*verts)
+ ax.plot(xs, ys, 'x--', lw=2, color='black', ms=10)
+
+ ax.text(-0.05, -0.05, 'P0')
+ ax.text(0.15, 1.05, 'P1')
+ ax.text(1.05, 0.85, 'P2')
+ ax.text(0.85, -0.05, 'P3')
+
+ ax.set_xlim(-0.1, 1.1)
+ ax.set_ylim(-0.1, 1.1)
+ plt.show()
+
+.. compound_paths:
+
+Compound paths
+==============
+
+All of the simple patch primitives in matplotlib, Rectangle, Circle,
+Polygon, etc, are implemented with simple path. Plotting functions
+like :meth:`~matplotlib.axes.Axes.hist` and
+:meth:`~matplotlib.axes.Axes.bar`, which create a number of
+primitives, eg a bunch of Rectangles, can usually be implemented more
+efficiently using a compund path. The reason ``bar`` creates a list
+of rectangles and not a compound path is largely historical: the
+:class:`~matplotlib.path.Path` code is comparatively new and ``bar``
+predates it. While we could change it now, it would break old code,
+so here we will cover how to create compound paths, replacing the
+functionality in bar, in case you need to do so in your own code for
+efficiency reasons, eg you are creating an animated bar plot.
+
+We will make the histogram chart by creating a series of rectangles
+for each histogram bar: the rectangle width is the bin width and the
+rectangle height is the number of datapoints in that bin. First we'll
+create some random normally distributed data and compute the
+histogram. Because numpy returns the bin edges and not centers, the
+length of ``bins`` is 1 greater than the length of ``n`` in the
+example below::
+
+ # histogram our data with numpy
+ data = np.random.randn(1000)
+ n, bins = np.histogram(data, 100)
+
+We'll now extract the corners of the rectangles. Each of the
+``left``, ``bottom``, etc, arrays below is ``len(n)``, where ``n`` is
+the array of counts for each histogram bar::
+
+ # get the corners of the rectangles for the histogram
+ left = np.array(bins[:-1])
+ right = np.array(bins[1:])
+ bottom = np.zeros(len(left))
+ top = bottom + n
+
+Now we have to construct our compound path, which will consist of a
+series of ``MOVETO``, ``LINETO`` and ``CLOSEPOLY`` for each rectangle.
+For each rectangle, we need 5 vertices: 1 for the ``MOVETO``, 3 for
+the ``LINETO``, and 1 for the ``CLOSEPOLY``. As indicated in the
+table above, the vertex for the closepoly is ignored but we still need
+it to keep the codes aligned with the vertices::
+
+ nverts = nrects*(1+3+1)
+ verts = np.zeros((nverts, 2))
+ codes = np.ones(nverts, int) * path.Path.LINETO
+ codes[0::5] = path.Path.MOVETO
+ codes[4::5] = path.Path.CLOSEPOLY
+ verts[0::5,0] = left
+ verts[0::5,1] = bottom
+ verts[1::5,0] = left
+ verts[1::5,1] = top
+ verts[2::5,0] = right
+ verts[2::5,1] = top
+ verts[3::5,0] = right
+ verts[3::5,1] = bottom
+
+All that remains is to create the path, attach it to a
+:class:`~matplotlib.patch.PathPatch`, and ad it to our axes::
+
+ barpath = path.Path(verts, codes)
+ patch = patches.PathPatch(barpath, facecolor='green',
+ edgecolor='yellow', alpha=0.5)
+ ax.add_patch(patch)
+
+Here is the result
+
+.. plot:: pyplots/compound_path_demo.py
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-08-23 01:22:21
|
Revision: 7523
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7523&view=rev
Author: jdh2358
Date: 2009-08-22 23:20:30 +0000 (Sat, 22 Aug 2009)
Log Message:
-----------
fix osx epd formatting bug in rest
Modified Paths:
--------------
branches/v0_99_maint/doc/_templates/indexsidebar.html
branches/v0_99_maint/doc/_templates/layout.html
branches/v0_99_maint/doc/faq/installing_faq.rst
branches/v0_99_maint/doc/users/transforms_tutorial.rst
Modified: branches/v0_99_maint/doc/_templates/indexsidebar.html
===================================================================
--- branches/v0_99_maint/doc/_templates/indexsidebar.html 2009-08-22 23:19:44 UTC (rev 7522)
+++ branches/v0_99_maint/doc/_templates/indexsidebar.html 2009-08-22 23:20:30 UTC (rev 7523)
@@ -7,18 +7,33 @@
pathto('users/installing') }}">installing</a>
</p>
-<p>Watch a <a href="http://videolectures.net/mloss08_hunter_mat">video lecture</a> about matplotlib presented at <a href="http://videolectures.net/mloss08_whistler">NIPS 08 Workshop</a> <i>Machine Learning Open Source Software</i></a>.
+<p>Build websites like matplotlib's,
+with <a href="http://sphinx.pocoo.org/">sphinx</a> and extensions for
+mpl plots, math, inheritance diagrams -- try
+the <a href="http://matplotlib.sf.net/sampledoc">sampledoc</a>
+tutorial.
</p>
+
+<h3>Videos</h3>
+
+<p>Watch the <a href="http://conference.scipy.org/">SciPy</a> 2009 <a href="http://www.archive.org/details/scipy09_introTutorialDay2_1">intro</a> and <a href="http://www.archive.org/details/scipy09_advancedTutorialDay1_3">advanced</a> matplotlib tutorials
+</p>
+
+<p>Watch a <a href="http://videolectures.net/mloss08_hunter_mat">talk</a> about matplotlib presented at <a href="http://videolectures.net/mloss08_whistler">NIPS 08 Workshop</a> <i>MLOSS</i></a>.
+</p>
+
+
+<h3>Toolkits</h3>
+
<p>There are several matplotlib addon <a href="{{
pathto('users/toolkits') }}">toolkits</a>, including the projection
and mapping toolkit
<a href="http://matplotlib.sf.net/basemap/doc/html">basemap</a>, 3d plotting with <a href="{{
-pathto('mpl_toolkits/mplot3d/index') }}">mplot3d</a>, wild and wonderful axes and axis helpers in <a href="{{
+pathto('mpl_toolkits/mplot3d/index') }}">mplot3d</a>, axes and axis helpers in <a href="{{
pathto('mpl_toolkits/axes_grid/index') }}">axes_grid</a> and more.
</p>
-
<h3>Need help?</h3>
<p>Check the <a href="{{ pathto('users/index') }}">user guide</a>,
Modified: branches/v0_99_maint/doc/_templates/layout.html
===================================================================
--- branches/v0_99_maint/doc/_templates/layout.html 2009-08-22 23:19:44 UTC (rev 7522)
+++ branches/v0_99_maint/doc/_templates/layout.html 2009-08-22 23:20:30 UTC (rev 7523)
@@ -2,10 +2,11 @@
{% block rootrellink %}
- <li><a href="{{ pathto('index') }}">matplotlib home</a>| </li>
+ <li><a href="{{ pathto('index') }}">home</a>| </li>
<li><a href="{{ pathto('search') }}">search</a>| </li>
+ <li><a href="examples/index.html">examples</a>| </li>
<li><a href="{{ pathto('gallery') }}">gallery</a>| </li>
- <li><a href="{{ pathto('contents') }}">documentation </a> »</li>
+ <li><a href="{{ pathto('contents') }}">docs</a> »</li>
{% endblock %}
Modified: branches/v0_99_maint/doc/faq/installing_faq.rst
===================================================================
--- branches/v0_99_maint/doc/faq/installing_faq.rst 2009-08-22 23:19:44 UTC (rev 7522)
+++ branches/v0_99_maint/doc/faq/installing_faq.rst 2009-08-22 23:20:30 UTC (rev 7523)
@@ -400,9 +400,10 @@
``/Library/Frameworks/Python.framework/Versions/Current/lib/pythonX.Y/site-packages/easy-install.pth``,
(where X.Y is the version of Python you are building against)
Comment out the line containing the name of the directory in which the
-previous version of MPL was installed (Looks something like ``./matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg``).
+previous version of MPL was installed (Looks something like ``./matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg``).
3. Save the following as a shell script , for example ``./install-matplotlib-epd-osx.sh`` ::
+
NAME=matplotlib
VERSION=0_99
PREFIX=$HOME
@@ -413,11 +414,11 @@
echo getting the trunk
svn co https://matplotlib.svn.sourceforge.net/svnroot/$NAME/trunk/$NAME $NAME
cd $NAME
-
+
fi
if [ $branch = "release" ]
then
- echo getting the maintenance branch
+ echo getting the maintenance branch
svn co https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v${VERSION}_maint $NAME$VERSION
cd $NAME$VERSION
fi
Modified: branches/v0_99_maint/doc/users/transforms_tutorial.rst
===================================================================
--- branches/v0_99_maint/doc/users/transforms_tutorial.rst 2009-08-22 23:19:44 UTC (rev 7522)
+++ branches/v0_99_maint/doc/users/transforms_tutorial.rst 2009-08-22 23:20:30 UTC (rev 7523)
@@ -12,11 +12,12 @@
happens under the hood, but as you push the limits of custom figure
generation, it helps to have an understanding of these objects so you
can reuse the existing transformations matplotlib makes available to
-you, or create your own (see :mod:`matplotlib.transforms`. The table below summarizes the existing
-coordinate systems, the transformation object you should use to work
-in that coordinate system, and the description of that system. In the
-`Transformation Object` column, ``ax`` is a :class:`~matplotlib.axes.Axes` instance,
-and ``fig`` is a :class:`~matplotlib.figure.Figure` instance.
+you, or create your own (see :mod:`matplotlib.transforms`). The table
+below summarizes the existing coordinate systems, the transformation
+object you should use to work in that coordinate system, and the
+description of that system. In the `Transformation Object` column,
+``ax`` is a :class:`~matplotlib.axes.Axes` instance, and ``fig`` is a
+:class:`~matplotlib.figure.Figure` instance.
========== ===================== ==============================================================================================================================================================
Coordinate Transformation Object Description
@@ -28,16 +29,18 @@
========== ===================== ==============================================================================================================================================================
-All of the transformation objects take inputs in their coordinate
-system, and transform the input to the `display` coordinate system.
-That is why the `display` coordinate system has `None` for the
-`Transformation Object` column -- it already is in display
-coordinates. The transformations also know how to invert themselves,
-to go from `display` back to the native coordinate system. This is
-particularly useful when processing events from the user interface,
-which typically occur in display space, and you want to know where the
-mouse click or key-press occurred in your data coordinate system.
+All of the transformation objects in the table above take inputs in
+their coordinate system, and transform the input to the `display`
+coordinate system. That is why the `display` coordinate system has
+`None` for the `Transformation Object` column -- it already is in
+display coordinates. The transformations also know how to invert
+themselves, to go from `display` back to the native coordinate system.
+This is particularly useful when processing events from the user
+interface, which typically occur in display space, and you want to
+know where the mouse click or key-press occurred in your data
+coordinate system.
+
.. _data-coords:
Data coordinates
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-08-29 16:35:46
|
Revision: 7582
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7582&view=rev
Author: jdh2358
Date: 2009-08-29 16:35:35 +0000 (Sat, 29 Aug 2009)
Log Message:
-----------
added Michael Sarahan's image tutorial from the scipy mpl sprint
Modified Paths:
--------------
branches/v0_99_maint/doc/_templates/indexsidebar.html
branches/v0_99_maint/doc/_templates/layout.html
branches/v0_99_maint/doc/devel/coding_guide.rst
branches/v0_99_maint/doc/users/index.rst
branches/v0_99_maint/doc/users/transforms_tutorial.rst
branches/v0_99_maint/doc/users/whats_new.rst
Added Paths:
-----------
branches/v0_99_maint/doc/_static/stinkbug.png
branches/v0_99_maint/doc/users/image_tutorial.rst
Added: branches/v0_99_maint/doc/_static/stinkbug.png
===================================================================
(Binary files differ)
Property changes on: branches/v0_99_maint/doc/_static/stinkbug.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: branches/v0_99_maint/doc/_templates/indexsidebar.html
===================================================================
--- branches/v0_99_maint/doc/_templates/indexsidebar.html 2009-08-28 12:20:11 UTC (rev 7581)
+++ branches/v0_99_maint/doc/_templates/indexsidebar.html 2009-08-29 16:35:35 UTC (rev 7582)
@@ -52,7 +52,7 @@
but it is a good idea to ping us on the mailing list too.</p>
<p>For details on what's new, see the detailed <a href="{{
-pathto('_static/CHANGELOG', 1) }}">changelog</a>. Anything that could
+pathto('_static/CHANGELOG', 1) }}">changelog</a> or browse the <a href="http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/">source code</a>. Anything that could
require changes to your existing codes is logged in the <a href="{{
pathto('api/api_changes.html', 1) }}">api changes</a> file.</p>
Modified: branches/v0_99_maint/doc/_templates/layout.html
===================================================================
--- branches/v0_99_maint/doc/_templates/layout.html 2009-08-28 12:20:11 UTC (rev 7581)
+++ branches/v0_99_maint/doc/_templates/layout.html 2009-08-29 16:35:35 UTC (rev 7582)
@@ -4,7 +4,7 @@
{% block rootrellink %}
<li><a href="{{ pathto('index') }}">home</a>| </li>
<li><a href="{{ pathto('search') }}">search</a>| </li>
- <li><a href="examples/index.html">examples</a>| </li>
+ <li><a href="http://matplotlib.sf.net/examples/index.html">examples</a>| </li>
<li><a href="{{ pathto('gallery') }}">gallery</a>| </li>
<li><a href="{{ pathto('contents') }}">docs</a> »</li>
{% endblock %}
Modified: branches/v0_99_maint/doc/devel/coding_guide.rst
===================================================================
--- branches/v0_99_maint/doc/devel/coding_guide.rst 2009-08-28 12:20:11 UTC (rev 7581)
+++ branches/v0_99_maint/doc/devel/coding_guide.rst 2009-08-29 16:35:35 UTC (rev 7582)
@@ -1,4 +1,4 @@
-M.. _coding-guide:
+.. _coding-guide:
************
Coding guide
Added: branches/v0_99_maint/doc/users/image_tutorial.rst
===================================================================
--- branches/v0_99_maint/doc/users/image_tutorial.rst (rev 0)
+++ branches/v0_99_maint/doc/users/image_tutorial.rst 2009-08-29 16:35:35 UTC (rev 7582)
@@ -0,0 +1,324 @@
+.. _image_tutorial:
+
+
+**************
+Image tutorial
+**************
+
+.. _imaging_startup:
+
+Startup commands
+===================
+
+At the very least, you'll need to have access to the :func:`~matplotlib.pyplot.imshow` function. There are a couple of ways to do it. The easy way for an interactive environment::
+
+ $ipython -pylab -wthread
+
+The imshow function is now directly accessible (it's in your
+`namespace <http://bytebaker.com/2008/07/30/python-namespaces/>`_).
+See also :ref:`pyplot-tutorial`.
+
+The more expressive, easier to understand later method (use this in your scripts to make it easier for others (including your future self) to read)::
+
+ $ipython -wthread
+
+.. sourcecode:: ipython
+
+ In [1]: import matplotlib.pyplot as plt
+ In [2]: import matplotlib.image as mpimg
+ In [3]: import numpy as np
+
+Examples below will use the latter method, for clarity. In these examples, if you use the -pylab method, you can skip the "mpimg." and "plt." prefixes.
+
+.. _importing_data:
+
+Importing image data into Numpy arrays
+===============================================
+
+Plotting image data is supported by the Python Image Library (`PIL <http://www.pythonware.com/products/pil/>`_), . Natively, matplotlib only supports PNG images. The commands shown below fall back on PIL if the native read fails.
+
+The image used in this example is a PNG file, but keep that PIL requirement in mind for your own data.
+
+Here's the image we're going to play with:
+
+.. image:: ../_static/stinkbug.png
+
+It's a 24-bit RGB PNG image (8 bits for each of R, G, B). Depending
+on where you get your data, the other kinds of image that you'll most
+likely encounter are RGBA images, which allow for transparency, or
+single-channel grayscale (luminosity) images. You can right click on
+it and choose "Save image as" to download it to your computer for the
+rest of this tutorial.
+
+And here we go...
+
+.. sourcecode:: ipython
+
+ In [4]: img=mpimg.imread('stinkbug.png')
+ Out[4]:
+ array([[[ 0.40784314, 0.40784314, 0.40784314],
+ [ 0.40784314, 0.40784314, 0.40784314],
+ [ 0.40784314, 0.40784314, 0.40784314],
+ ...,
+ [ 0.42745098, 0.42745098, 0.42745098],
+ [ 0.42745098, 0.42745098, 0.42745098],
+ [ 0.42745098, 0.42745098, 0.42745098]],
+
+ [[ 0.41176471, 0.41176471, 0.41176471],
+ [ 0.41176471, 0.41176471, 0.41176471],
+ [ 0.41176471, 0.41176471, 0.41176471],
+ ...,
+ [ 0.42745098, 0.42745098, 0.42745098],
+ [ 0.42745098, 0.42745098, 0.42745098],
+ [ 0.42745098, 0.42745098, 0.42745098]],
+
+ [[ 0.41960785, 0.41960785, 0.41960785],
+ [ 0.41568628, 0.41568628, 0.41568628],
+ [ 0.41568628, 0.41568628, 0.41568628],
+ ...,
+ [ 0.43137255, 0.43137255, 0.43137255],
+ [ 0.43137255, 0.43137255, 0.43137255],
+ [ 0.43137255, 0.43137255, 0.43137255]],
+
+ ...,
+ [[ 0.43921569, 0.43921569, 0.43921569],
+ [ 0.43529412, 0.43529412, 0.43529412],
+ [ 0.43137255, 0.43137255, 0.43137255],
+ ...,
+ [ 0.45490196, 0.45490196, 0.45490196],
+ [ 0.4509804 , 0.4509804 , 0.4509804 ],
+ [ 0.4509804 , 0.4509804 , 0.4509804 ]],
+
+ [[ 0.44313726, 0.44313726, 0.44313726],
+ [ 0.44313726, 0.44313726, 0.44313726],
+ [ 0.43921569, 0.43921569, 0.43921569],
+ ...,
+ [ 0.4509804 , 0.4509804 , 0.4509804 ],
+ [ 0.44705883, 0.44705883, 0.44705883],
+ [ 0.44705883, 0.44705883, 0.44705883]],
+
+ [[ 0.44313726, 0.44313726, 0.44313726],
+ [ 0.4509804 , 0.4509804 , 0.4509804 ],
+ [ 0.4509804 , 0.4509804 , 0.4509804 ],
+ ...,
+ [ 0.44705883, 0.44705883, 0.44705883],
+ [ 0.44705883, 0.44705883, 0.44705883],
+ [ 0.44313726, 0.44313726, 0.44313726]]], dtype=float32)
+
+Note the dtype there - float32. Matplotlib has rescaled the 8 bit data from each channel to floating point data between 0.0 and 1.0. As a side note, the only datatype that PIL can work with is uint8. Matplotlib plotting can handle float32 and uint8, but image reading/writing for any format other than PNG is limited to uint8 data. Why 8 bits? Most displays can only render 8 bits per channel worth of color gradation. Why can they only render 8 bits/channel? Because that's about all the human eye can see. More here (from a photography standpoint): `Luminous Landscape bit depth tutorial <http://www.luminous-landscape.com/tutorials/bit-depth.shtml>`_
+
+Each inner list represents a pixel. Here, with an RGB image, there are 3 values. Since it's a black and white image, R, G, and B are all similar. An RGBA (where A is alpha, or transparency), has 4 values per inner list, and a simple luminance image just has one value (and is thus only a 2-D array, not a 3-D array). For RGB and RGBA images, matplotlib supports float32 and uint8 data types. For grayscale, matplotlib supports only float32. If your array data does not meet one of these descriptions, you need to rescale it.
+
+.. _plotting_data:
+
+Plotting numpy arrays as images
+===================================
+
+So, you have your data in a numpy array (either by importing it, or by generating it). Let's render it. In Matplotlib, this is performed using the :func:`~matplotlib.pyplot.imshow` function. Here we'll grab the plot object. This object gives you an easy way to manipulate the plot from the prompt.
+
+.. sourcecode:: ipython
+
+ In [5]: imgplot = plt.imshow(img)
+
+.. plot::
+
+ import matplotlib.pyplot as plt
+ import matplotlib.image as mpimg
+ import numpy as np
+ img = mpimg.imread('_static/stinkbug.png')
+ imgplot = plt.imshow(img)
+
+You can also plot any numpy array - just remember that the datatype must be float32 (and range from 0.0 to 1.0) or uint8.
+
+.. _Pseudocolor:
+
+Applying pseudocolor schemes to image plots
+-------------------------------------------------
+
+Pseudocolor can be a useful tool for enhancing contrast and visualizing your data more easily. This is especially useful when making presentations of your data using projectors - their contrast is typically quite poor.
+
+Pseudocolor is only relevant to single-channel, grayscale, luminosity images. We currently have an RGB image. Since R, G, and B are all similar (see for yourself above or in your data), we can just pick on channel of our data:
+
+.. sourcecode:: ipython
+
+ In [6]: lum_img = img[:,:,0]
+
+This is array slicing. You can read more `here <http://www.scipy.org/Tentative_NumPy_Tutorial>`_
+
+.. sourcecode:: ipython
+
+ In [7]: imgplot = mpimg.imshow(lum_img)
+
+.. plot::
+
+ import matplotlib.pyplot as plt
+ import matplotlib.image as mpimg
+ import numpy as np
+ img = mpimg.imread('_static/stinkbug.png')
+ lum_img = img[:,:,0]
+ plt.imshow(lum_img)
+
+Now, with a luminosity image, the default colormap (aka lookup table, LUT), is applied. The default is called jet. There are plenty of others to choose from. Let's set some others using the :meth:`~matplotlib.image.Image.set_cmap` method on our image plot object:
+
+.. sourcecode:: ipython
+
+ In [8]: imgplot.set_cmap('hot')
+
+.. plot::
+
+ import matplotlib.pyplot as plt
+ import matplotlib.image as mpimg
+ import numpy as np
+ img = mpimg.imread('_static/stinkbug.png')
+ lum_img = img[:,:,0]
+ imgplot = plt.imshow(lum_img)
+ imgplot.set_cmap('hot')
+
+.. sourcecode:: ipython
+
+ In [9]: imgplot.set_cmap('spectral')
+
+.. plot::
+
+ import matplotlib.pyplot as plt
+ import matplotlib.image as mpimg
+ import numpy as np
+ img = mpimg.imread('_static/stinkbug.png')
+ lum_img = img[:,:,0]
+ imgplot = plt.imshow(lum_img)
+ imgplot.set_cmap('spectral')
+
+There are many other colormap schemes available. See a list and images of the colormaps `here <http://matplotlib.sourceforge.net/examples/pylab_examples/show_colormaps.html>`_
+
+.. _Color Bars
+
+Color scale reference
+------------------------
+
+It's helpful to have an idea of what value a color represents. We can do that by adding color bars. It's as easy as one line:
+
+.. sourcecode:: ipython
+ In [10]: plt.colorbar()
+
+.. plot::
+
+ import matplotlib.pyplot as plt
+ import matplotlib.image as mpimg
+ import numpy as np
+ img = mpimg.imread('_static/stinkbug.png')
+ lum_img = img[:,:,0]
+ imgplot = plt.imshow(lum_img)
+ imgplot.set_cmap('spectral')
+ plt.colorbar()
+
+This adds a colorbar to your existing figure. This won't automatically change if you change you switch to a different colormap - you have to re-create your plot, and add in the colorbar again.
+
+.. _Data ranges
+
+Examining a specific data range
+---------------------------------
+
+Sometimes you want to enhance the contrast in your image, or expand the contrast in a particular region while sacrificing the detail in colors that don't vary much, or don't matter. A good tool to find interesting regions is the histogram. To create a histogram of our image data, we use the :func:`~matplotlib.pyplot.hist` function.
+
+.. sourcecode:: ipython
+
+ In[10]: plt.hist(lum_img)
+
+.. plot::
+
+ import matplotlib.pyplot as plt
+ import matplotlib.image as mpimg
+ import numpy as np
+ img = mpimg.imread('_static/stinkbug.png')
+ lum_img = img[:,:,0]
+ plt.hist(lum_img, range=(0.0,1.0))
+
+Most often, the "interesting" part of the image is around the peak, and you can get extra contrast by clipping the regions above and/or below the peak. In our histogram, it looks like there's not much useful information in the high end (not many white things in the image). Let's adjust the upper limit, so that we effectively "zoom in on" part of the histogram. We do this by calling the :meth:`~matplotlib.image.Image.set_clim` method of the image plot object.
+
+.. sourcecode:: ipython
+
+ In[11]: imgplot.set_clim=(0.0,0.7)
+
+.. plot::
+
+ import matplotlib.pyplot as plt
+ import matplotlib.image as mpimg
+ import numpy as np
+ fig = plt.figure()
+ a=fig.add_subplot(1,2,1)
+ img = mpimg.imread('_static/stinkbug.png')
+ lum_img = img[:,:,0]
+ imgplot = plt.imshow(lum_img)
+ a.set_title('Before')
+ plt.colorbar(ticks=[0.1,0.3,0.5,0.7], orientation ='horizontal')
+ a=fig.add_subplot(1,2,2)
+ imgplot = plt.imshow(lum_img)
+ imgplot.set_clim(0.0,0.7)
+ a.set_title('After')
+ plt.colorbar(ticks=[0.1,0.3,0.5,0.7], orientation='horizontal')
+
+.. _Interpolation:
+
+Array Interpolation schemes
+-----------------------------------
+Interpolation calculates what the color or value of a pixel "should" be, according to different mathematical schemes. One common place that this happens is when you resize an image. The number of pixels change, but you want the same information. Since pixels are discrete, there's missing space. Interpolation is how you fill that space. This is why your images sometimes come out looking pixelated when you blow them up. The effect is more pronounced when the difference between the original image and the expanded image is greater. Let's take our image and shrink it. We're effectively discarding pixels, only keeping a select few. Now when we plot it, that data gets blown up to the size on your screen. The old pixels aren't there anymore, and the computer has to draw in pixels to fill that space.
+
+.. sourcecode:: ipython
+
+ In [8]: import Image
+ In [9]: img = Image.open('stinkbug.png') # Open image as PIL image object
+ In [10]: rsize = img.resize((img.size[0]/10,img.size[1]/10)) # Use PIL to resize
+ In [11]: rsizeArr = np.asarray(rsize) # Get array back
+ In [12]: imgplot = mpimg.imshow(rsizeArr)
+
+.. plot::
+
+ import matplotlib.pyplot as plt
+ import matplotlib.image as mpimg
+ import numpy as np
+ import Image
+ img = Image.open('_static/stinkbug.png') # opens the file using PIL - it's not an array yet
+ rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
+ rsizeArr = np.asarray(rsize)
+ lum_img = rsizeArr[:,:,0]
+ imgplot = plt.imshow(rsizeArr)
+
+Here we have the default interpolation, bilinear, since we did not give :func:`~matplotlib.pyplot.imshow` any interpolation argument.
+
+Let's try some others:
+
+.. sourcecode:: ipython
+
+ In [10]: imgplot.set_interpolation('nearest')
+
+.. plot::
+
+ import matplotlib.pyplot as plt
+ import matplotlib.image as mpimg
+ import numpy as np
+ import Image
+ img = Image.open('_static/stinkbug.png') # opens the file using PIL - it's not an array yet
+ rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
+ rsizeArr = np.asarray(rsize)
+ lum_img = rsizeArr[:,:,0]
+ imgplot = plt.imshow(rsizeArr)
+ imgplot.set_interpolation('nearest')
+
+.. sourcecode:: ipython
+
+ In [10]: imgplot.set_interpolation('bicubic')
+
+.. plot::
+
+ import matplotlib.pyplot as plt
+ import matplotlib.image as mpimg
+ import numpy as np
+ import Image
+ img = Image.open('_static/stinkbug.png') # opens the file using PIL - it's not an array yet
+ rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
+ rsizeArr = np.asarray(rsize)
+ lum_img = rsizeArr[:,:,0]
+ imgplot = plt.imshow(rsizeArr)
+ imgplot.set_interpolation('bicubic')
+
+Bicubic interpolation is often used when blowing up photos - people tend to prefer blurry over pixelated.
\ No newline at end of file
Modified: branches/v0_99_maint/doc/users/index.rst
===================================================================
--- branches/v0_99_maint/doc/users/index.rst 2009-08-28 12:20:11 UTC (rev 7581)
+++ branches/v0_99_maint/doc/users/index.rst 2009-08-29 16:35:35 UTC (rev 7582)
@@ -19,6 +19,7 @@
customizing.rst
shell.rst
index_text.rst
+ image_tutorial.rst
artists.rst
legend_guide.rst
event_handling.rst
Modified: branches/v0_99_maint/doc/users/transforms_tutorial.rst
===================================================================
--- branches/v0_99_maint/doc/users/transforms_tutorial.rst 2009-08-28 12:20:11 UTC (rev 7581)
+++ branches/v0_99_maint/doc/users/transforms_tutorial.rst 2009-08-29 16:35:35 UTC (rev 7582)
@@ -1,4 +1,4 @@
-.. _transformstutorial:
+.. _transforms_tutorial:
**************************
Transformations Tutorial
Modified: branches/v0_99_maint/doc/users/whats_new.rst
===================================================================
--- branches/v0_99_maint/doc/users/whats_new.rst 2009-08-28 12:20:11 UTC (rev 7581)
+++ branches/v0_99_maint/doc/users/whats_new.rst 2009-08-29 16:35:35 UTC (rev 7582)
@@ -12,6 +12,16 @@
.. _whats-new-mplot3d:
+New documentation
+-----------------
+
+Jae-Joon Lee has written two new guides :ref:`plotting-guide-legend`
+and :ref:`plotting-guide-annotation`. Michael Sarahan has written
+:ref:`image_tutorial`. John Hunter has written two new tutorials on
+working with paths and transformations: :ref:`path_tutorial` and
+:ref:`transforms_tutorial`.
+
+
mplot3d
--------
@@ -53,12 +63,6 @@
.. plot:: pyplots/whats_new_99_spines.py
-New documentation
------------------
-
-jae-Joon Lee has written two new guides :ref:`plotting-guide-legend`
-and :ref:`plotting-guide-annotation`.
-
.. _whats-new-0-98-4:
new in 0.98.4
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-09-11 02:06:38
|
Revision: 7741
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7741&view=rev
Author: jdh2358
Date: 2009-09-11 02:06:30 +0000 (Fri, 11 Sep 2009)
Log Message:
-----------
minor tweaks to licensing devel doc
Modified Paths:
--------------
branches/v0_99_maint/doc/devel/coding_guide.rst
branches/v0_99_maint/doc/users/credits.rst
Modified: branches/v0_99_maint/doc/devel/coding_guide.rst
===================================================================
--- branches/v0_99_maint/doc/devel/coding_guide.rst 2009-09-11 01:54:27 UTC (rev 7740)
+++ branches/v0_99_maint/doc/devel/coding_guide.rst 2009-09-11 02:06:30 UTC (rev 7741)
@@ -578,7 +578,7 @@
The two dominant license variants in the wild are GPL-style and
BSD-style. There are countless other licenses that place specific
-restrictions on code reuse, but there is an important different to be
+restrictions on code reuse, but there is an important difference to be
considered in the GPL and BSD variants. The best known and perhaps
most widely used license is the GPL, which in addition to granting you
full rights to the source code including redistribution, carries with
@@ -587,7 +587,7 @@
license. I.e., you are required to give the source code to other
people and give them the right to redistribute it as well. Many of the
most famous and widely used open source projects are released under
-the GPL, including sagemath, linux, gcc and emacs.
+the GPL, including linux, gcc, emacs and sage.
The second major class are the BSD-style licenses (which includes MIT
and the python PSF license). These basically allow you to do whatever
@@ -606,20 +606,20 @@
sense of the last paragraph are the BSD operating system, python and
TeX.
-There are two primary reasons why early matplotlib developers selected
-a BSD compatible license. We wanted to attract as many users and
-developers as possible, and many software companies will not use GPL code
-in software they plan to distribute, even those that are highly
-committed to open source development, such as `enthought
+There are several reasons why early matplotlib developers selected a
+BSD compatible license. matplotlib is a python extension, and we
+choose a license that was based on the python license (BSD
+compatible). Also, we wanted to attract as many users and developers
+as possible, and many software companies will not use GPL code in
+software they plan to distribute, even those that are highly committed
+to open source development, such as `enthought
<http://enthought.com>`_, out of legitimate concern that use of the
GPL will "infect" their code base by its viral nature. In effect, they
-want to retain the right to release some proprietary code. Companies,
-and institutions in general, who use matplotlib often make significant
-contributions, since they have the resources to get a job done, even a
-boring one, if they need it in their code. Two of the matplotlib
-backends (FLTK and WX) were contributed by private companies.
-
-The other reason is licensing compatibility with the other python
-extensions for scientific computing: ipython, numpy, scipy, the
-enthought tool suite and python itself are all distributed under BSD
-compatible licenses.
+want to retain the right to release some proprietary code. Companies
+and institutions who use matplotlib often make significant
+contributions, because they have the resources to get a job done, even
+a boring one. Two of the matplotlib backends (FLTK and WX) were
+contributed by private companies. The final reason behind the
+licensing choice is compatibility with the other python extensions for
+scientific computing: ipython, numpy, scipy, the enthought tool suite
+and python itself are all distributed under BSD compatible licenses.
Modified: branches/v0_99_maint/doc/users/credits.rst
===================================================================
--- branches/v0_99_maint/doc/users/credits.rst 2009-09-11 01:54:27 UTC (rev 7740)
+++ branches/v0_99_maint/doc/users/credits.rst 2009-09-11 02:06:30 UTC (rev 7741)
@@ -18,7 +18,11 @@
Andrew Straw provided much of the log scaling architecture, the fill
command, PIL support for imshow, and provided many examples. He
- also wrote the support for dropped axis spines.
+ also wrote the support for dropped axis spines and the `buildbot
+ <http://mpl-buildbot.code.astraw.com/>`_ unit testing infrastructure
+ which triggers the JPL/James Evans platform specific builds and
+ regression test image comparisons from svn matplotlib across
+ platforms on svn commits.
Charles Twardy
provided the impetus code for the legend class and has made
@@ -116,11 +120,14 @@
at `NOAA <http://www.boulder.noaa.gov>`_ wrote the
:ref:`toolkit_basemap` tookit
-Sigve Tjoraand, Ted Drain
+Sigve Tjoraand, Ted Drain, James Evans
and colleagues at the `JPL <http://www.jpl.nasa.gov>`_ collaborated
on the QtAgg backend and sponsored development of a number of
features including custom unit types, datetime support, scale free
- ellipses, broken bar plots and more.
+ ellipses, broken bar plots and more. The JPL team wrote the unit
+ testing image comparison `infrastructure
+ <http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/test>`_
+ for regression test image comparisons.
James Amundson
did the initial work porting the qt backend to qt4
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2010-03-03 15:47:55
|
Revision: 8171
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8171&view=rev
Author: jdh2358
Date: 2010-03-03 15:47:48 +0000 (Wed, 03 Mar 2010)
Log Message:
-----------
added favicon
Modified Paths:
--------------
branches/v0_99_maint/doc/_templates/layout.html
Added Paths:
-----------
branches/v0_99_maint/doc/_static/favicon.ico
Added: branches/v0_99_maint/doc/_static/favicon.ico
===================================================================
(Binary files differ)
Property changes on: branches/v0_99_maint/doc/_static/favicon.ico
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: branches/v0_99_maint/doc/_templates/layout.html
===================================================================
--- branches/v0_99_maint/doc/_templates/layout.html 2010-03-02 13:12:16 UTC (rev 8170)
+++ branches/v0_99_maint/doc/_templates/layout.html 2010-03-03 15:47:48 UTC (rev 8171)
@@ -23,8 +23,8 @@
</script>
<object><noscript><p><img src="http://apps.sourceforge.net/piwik/matplotlib/piwik.php?idsite=1" alt="piwik"/></p></noscript></object>
<!-- End Piwik Tag -->
+<link rel="shortcut icon" href="favicon.ico">
-
<div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px">
<a href="{{ pathto('index') }}"><img src="{{
pathto("_static/logo2.png", 1) }}" border="0" alt="matplotlib"/></a>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|