You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
| 2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
| 2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
| 2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <lee...@us...> - 2009-07-14 21:24:12
|
Revision: 7262
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7262&view=rev
Author: leejjoon
Date: 2009-07-14 21:24:07 +0000 (Tue, 14 Jul 2009)
Log Message:
-----------
initial submission of the annotation guide.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/doc/users/plotting.rst
Added Paths:
-----------
trunk/matplotlib/doc/users/plotting/annotation.rst
trunk/matplotlib/doc/users/plotting/examples/anchored_box01.py
trunk/matplotlib/doc/users/plotting/examples/anchored_box02.py
trunk/matplotlib/doc/users/plotting/examples/anchored_box03.py
trunk/matplotlib/doc/users/plotting/examples/anchored_box04.py
trunk/matplotlib/doc/users/plotting/examples/annotate_explain.py
trunk/matplotlib/doc/users/plotting/examples/annotate_simple01.py
trunk/matplotlib/doc/users/plotting/examples/annotate_simple02.py
trunk/matplotlib/doc/users/plotting/examples/annotate_simple03.py
trunk/matplotlib/doc/users/plotting/examples/annotate_simple04.py
trunk/matplotlib/doc/users/plotting/examples/annotate_text_arrow.py
trunk/matplotlib/doc/users/plotting/examples/axes_zoom_effect.py
trunk/matplotlib/doc/users/plotting/examples/connect_simple01.py
trunk/matplotlib/doc/users/plotting/examples/connectionstyle_demo.py
trunk/matplotlib/doc/users/plotting/examples/custom_boxstyle01.py
trunk/matplotlib/doc/users/plotting/examples/custom_boxstyle02.py
trunk/matplotlib/doc/users/plotting/examples/simple_annotate01.py
trunk/matplotlib/examples/pylab_examples/axes_zoom_effect.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-07-14 21:18:58 UTC (rev 7261)
+++ trunk/matplotlib/CHANGELOG 2009-07-14 21:24:07 UTC (rev 7262)
@@ -1,3 +1,5 @@
+2009-07-14 initial submission of the annotation guide. -JJL
+
2009-07-14 axes_grid : minor improvements in anchored_artists and
inset_locator. -JJL
Added: trunk/matplotlib/doc/users/plotting/annotation.rst
===================================================================
--- trunk/matplotlib/doc/users/plotting/annotation.rst (rev 0)
+++ trunk/matplotlib/doc/users/plotting/annotation.rst 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,332 @@
+.. _plotting-guide-annotation:
+
+****************
+Annotating Axes
+****************
+
+Do not proceed unless you already have read
+:func:`~matplotlib.pyplot.text` and :func:`~matplotlib.pyplot.annotate`!
+
+
+Annotating with Text with Box
+=============================
+
+Let's start with a simple example.
+
+.. plot:: users/plotting/examples/annotate_text_arrow.py
+
+
+The :func:`~matplotlib.pyplot.text` function in the pyplot module (or
+text method of the Axes class) takes bbox keyword argument, and when
+given, a box around the text is drawn. ::
+
+ bbox_props = dict(boxstyle="rarrow,pad=0.3", fc="cyan", ec="b", lw=2)
+ t = ax.text(0, 0, "Direction", ha="center", va="center", rotation=45,
+ size=15,
+ bbox=bbox_props)
+
+
+The patch object associated with the text can be accessed by::
+
+ bb = t.get_bbox_patch()
+
+The return value is an instance of FancyBboxPatch and the patch
+properties like facecolor, edgewidth, etc. can be accessed and
+modified as usual. To change the shape of the box, use *set_boxstyle*
+method. ::
+
+ bb.set_boxstyle("rarrow", pad=0.6)
+
+The arguments are the name of the box style with its attributes as
+keyword arguments. Currently, followign box styles are implemented.
+
+ ========== ============== ==========================
+ Class Name Attrs
+ ========== ============== ==========================
+ LArrow ``larrow`` pad=0.3
+ RArrow ``rarrow`` pad=0.3
+ Round ``round`` pad=0.3,rounding_size=None
+ Round4 ``round4`` pad=0.3,rounding_size=None
+ Roundtooth ``roundtooth`` pad=0.3,tooth_size=None
+ Sawtooth ``sawtooth`` pad=0.3,tooth_size=None
+ Square ``square`` pad=0.3
+ ========== ============== ==========================
+
+.. plot:: mpl_examples/pylab_examples/fancybox_demo2.py
+
+
+Note that the attrubutes arguments can be specified within the style
+name with separating comma (this form can be used as "boxstyle" value
+of bbox argument when initializing the text instance) ::
+
+ bb.set_boxstyle("rarrow,pad=0.6")
+
+
+
+
+Annotating with Arrow
+=====================
+
+The :func:`~matplotlib.pyplot.annotate` function in the pyplot module
+(or annotate method of the Axes class) is used to draw an arrow
+connecting two points on the plot. ::
+
+ ax.annotate("Annotation",
+ xy=(x1, y1), xycoords='data',
+ xytext=(x2, y2), textcoords='offset points',
+ )
+
+This annotates a point at ``xy`` in the given coordinate (``xycoords``)
+with the text at ``xytext`` given in ``textcoords``. Often, the
+annotated point is specified in the *data* coordinate and the annotating
+text in *offset points*.
+See :func:`~matplotlib.pyplot.annotate` for available coordinate systems.
+
+An arrow connecting two point (xy & xytext) can be optionally drawn by
+specifying the ``arrowprops`` argument. To draw only an arrow, use
+empty string as the first argument. ::
+
+ ax.annotate("",
+ xy=(0.2, 0.2), xycoords='data',
+ xytext=(0.8, 0.8), textcoords='data',
+ arrowprops=dict(arrowstyle="->",
+ connectionstyle="arc3"),
+ )
+
+.. plot:: users/plotting/examples/annotate_simple01.py
+
+The arrow drawing takes a few steps.
+
+1. a connecting path between two points are created. This is
+ controlled by ``connectionstyle`` key value.
+
+2. If patch object is given (*patchA* & *patchB*), the path is clipped to
+ avoid the patch.
+
+3. The path is further shrinked by given amount of pixels (*shirnkA*
+ & *shrinkB*)
+
+4. The path is transmuted to arrow patch, which is controlled by the
+ ``arrowstyle`` key value.
+
+
+.. plot:: users/plotting/examples/annotate_explain.py
+
+
+The creation of the connecting path between two points is controlled by
+``connectionstyle`` key and follwing styles are available.
+
+ ========== =============================================
+ Name Attrs
+ ========== =============================================
+ ``angle`` angleA=90,angleB=0,rad=0.0
+ ``angle3`` angleA=90,angleB=0
+ ``arc`` angleA=0,angleB=0,armA=None,armB=None,rad=0.0
+ ``arc3`` rad=0.0
+ ``bar`` armA=0.0,armB=0.0,fraction=0.3,angle=None
+ ========== =============================================
+
+Note that "3" in ``angle3`` and ``arc3`` is meant to indicate that the
+resulting path is a quadratic spline segment (three control
+points). As will be discussed below, some arrow style option only can
+be used when the connecting path is a quadratic spline.
+
+The behavior of each connection style is (limitedly) demonstrated in the
+example below. (Warning : The behavior of the ``bar`` style is currently not
+well defined, it may be changed in the future).
+
+.. plot:: users/plotting/examples/connectionstyle_demo.py
+
+
+The connecting path (after clipping and shrinking) is then mutated to
+an arrow patch, according to the given ``arrowstyle``.
+
+ ========== =============================================
+ Name Attrs
+ ========== =============================================
+ ``-`` None
+ ``->`` head_length=0.4,head_width=0.2
+ ``-[`` widthB=1.0,lengthB=0.2,angleB=None
+ ``-|>`` head_length=0.4,head_width=0.2
+ ``<-`` head_length=0.4,head_width=0.2
+ ``<->`` head_length=0.4,head_width=0.2
+ ``<|-`` head_length=0.4,head_width=0.2
+ ``<|-|>`` head_length=0.4,head_width=0.2
+ ``fancy`` head_length=0.4,head_width=0.4,tail_width=0.4
+ ``simple`` head_length=0.5,head_width=0.5,tail_width=0.2
+ ``wedge`` tail_width=0.3,shrink_factor=0.5
+ ========== =============================================
+
+.. plot:: mpl_examples/pylab_examples/fancyarrow_demo.py
+
+Some arrowstyles only work with connection style that generates a
+quadratic-spline segment. They are ``fancy``, ``simple``, and ``wedge``.
+For these arrow styles, you must use "angle3" or "arc3" connection
+style.
+
+If the annotation string is given, the patchA is set to the bbox patch
+of the text by default.
+
+.. plot:: users/plotting/examples/annotate_simple02.py
+
+As in the text command, a box around the text can be drawn using
+the ``bbox`` argument.
+
+.. plot:: users/plotting/examples/annotate_simple03.py
+
+By default, the starting point is set to the center of the text
+extent. This can be adjusted with ``relpos`` key value. The values
+are normalized to the extent of the text. For example, (0,0) means
+lower-left corner and (1,1) means top-right.
+
+.. plot:: users/plotting/examples/annotate_simple04.py
+
+
+Using ConnectorPatch
+====================
+
+The ConnectorPatch is like an annotation without a text. While the
+annotate function is recommended in most of situation, the
+ConnectorPatch is useful when you want to connect points in different
+axes. ::
+
+ from matplotlib.patches import ConnectionPatch
+ xy = (0.2, 0.2)
+ con = ConnectionPatch(xyA=xy, xyB=xy, coordsA="data", coordsB="data",
+ axesA=ax1, axesB=ax2)
+ ax2.add_artist(con)
+
+The above code connects point xy in data coordinate of ``ax1`` to
+point xy int data coordiante of ``ax2``. Here is a simple example.
+
+.. plot:: users/plotting/examples/connect_simple01.py
+
+
+While the ConnectorPatch instance can be added to any axes, but you
+may want it to be added to the axes in the latter (?) of the axes
+drawing order to prevent overlap (?) by other axes.
+
+
+Placing Artist at the anchored location of the Axes
+===================================================
+
+There are class of artist that can be placed at the anchored location
+of the Axes. A common example is the legend. This type of artists can
+be created by using the OffsetBox class. A few predefined classes are
+available in ``mpl_toolkits.axes_grid.anchored_artists``. ::
+
+ from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
+ at = AnchoredText("Figure 1a",
+ prop=dict(size=8), frameon=True,
+ loc=2,
+ )
+ at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
+ ax.add_artist(at)
+
+
+.. plot:: users/plotting/examples/anchored_box01.py
+
+
+The *loc* keyword has same meaning as in the legend command.
+
+A simple application is when the size of the artist (or collection of
+artists) is knwon in pixel size during the time of creation. For
+example, If you want to draw a circle with fixed size of 20 pixel x 20
+pixel (radius = 10 pixel), you can utilize
+``AnchoredDrawingArea``. The instance is created with a size of the
+drawing area (in pixel). And user can add arbitrary artist to the
+drawing area. Note that the extents of the artists that are added to
+the drawing area has nothing to do with the placement of the drawing
+area itself. The initial size only matters. ::
+
+ from mpl_toolkits.axes_grid.anchored_artists import AnchoredDrawingArea
+
+ ada = AnchoredDrawingArea(20, 20, 0, 0,
+ loc=1, pad=0., frameon=False)
+ p1 = Circle((10, 10), 10)
+ ada.drawing_area.add_artist(p1)
+ p2 = Circle((30, 10), 5, fc="r")
+ ada.drawing_area.add_artist(p2)
+
+The artists that are added to the drawing area should not have
+transform set (they will be overridden) and the dimension of those
+artists are interpreted as a pixel coordinate, i.e., the radius of the
+circles in above example are 10 pixel and 5 pixel, respectively.
+
+.. plot:: users/plotting/examples/anchored_box02.py
+
+Sometimes, you want to your artists scale with data coordinate (or
+other coordinate than canvas pixel). You can use
+``AnchoredAuxTransformBox`` class. This is similar to
+``AnchoredDrawingArea`` except that the extent of the artist is
+determined during the drawing time respecting the specified transform. ::
+
+ from mpl_toolkits.axes_grid.anchored_artists import AnchoredAuxTransformBox
+
+ box = AnchoredAuxTransformBox(ax.transData, loc=2)
+ el = Ellipse((0,0), width=0.1, height=0.4, angle=30) # in data coordinates!
+ box.drawing_area.add_artist(el)
+
+The ellipse in the above example will have width and height
+corresponds to 0.1 and 0.4 in data coordinate and will be
+automatically scaled when the view limits of the axes change.
+
+.. plot:: users/plotting/examples/anchored_box03.py
+
+As in the legend, the bbox_to_anchor argument can be set. Using the
+HPacker and VPacker, you can have an arrangement(?) of artist as in the
+legend (as a matter of fact, this is how the legend is created).
+
+.. plot:: users/plotting/examples/anchored_box04.py
+
+Note that unlike the legend, the ``bbox_transform`` is set
+to IdentityTransform by default.
+
+Advanced Topics
+***************
+
+Zoom effect between Axes
+========================
+
+mpl_toolkits.axes_grid.inset_locator defines some patch classs useful
+for interconnect two axes. Understanding the code requires some
+knowledge of how mpl's transform works. But, utilizing it will be
+straight forward.
+
+
+.. plot:: mpl_examples/pylab_examples/axes_zoom_effect.py
+
+
+Define Custom BoxStyle
+======================
+
+You can use a custom box style. The value for the ``boxstyle`` can be a
+callable object in following forms.::
+
+ def __call__(self, x0, y0, width, height, mutation_size,
+ aspect_ratio=1.):
+ """
+ Given the location and size of the box, return the path of
+ the box around it.
+
+ - *x0*, *y0*, *width*, *height* : location and size of the box
+ - *mutation_size* : a reference scale for the mutation.
+ - *aspect_ratio* : aspect-ration for the mutation.
+ """
+ path = ...
+ return path
+
+Here is a complete example.
+
+.. plot:: users/plotting/examples/custom_boxstyle01.py
+
+However, it is recommended that you derive from the
+matplotlib.patches.BoxStyle._Base as demonstrated below.
+
+.. plot:: users/plotting/examples/custom_boxstyle02.py
+ :include-source:
+
+
+Similarly, you can define custom ConnectionStyle and Custome ArrowStyle.
+See the source code of ``lib/matplotlib/patches.py`` and check
+how each style class is defined.
Added: trunk/matplotlib/doc/users/plotting/examples/anchored_box01.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/anchored_box01.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/anchored_box01.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,14 @@
+import matplotlib.pyplot as plt
+from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
+
+fig=plt.figure(1, figsize=(3,3))
+ax = plt.subplot(111)
+
+at = AnchoredText("Figure 1a",
+ prop=dict(size=15), frameon=True,
+ loc=2,
+ )
+at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
+ax.add_artist(at)
+
+plt.show()
Added: trunk/matplotlib/doc/users/plotting/examples/anchored_box02.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/anchored_box02.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/anchored_box02.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,18 @@
+from matplotlib.patches import Circle
+import matplotlib.pyplot as plt
+from mpl_toolkits.axes_grid.anchored_artists import AnchoredDrawingArea
+
+fig=plt.figure(1, figsize=(3,3))
+ax = plt.subplot(111)
+
+
+ada = AnchoredDrawingArea(40, 20, 0, 0,
+ loc=1, pad=0., frameon=False)
+p1 = Circle((10, 10), 10)
+ada.drawing_area.add_artist(p1)
+p2 = Circle((30, 10), 5, fc="r")
+ada.drawing_area.add_artist(p2)
+
+ax.add_artist(ada)
+
+plt.show()
Added: trunk/matplotlib/doc/users/plotting/examples/anchored_box03.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/anchored_box03.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/anchored_box03.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,14 @@
+from matplotlib.patches import Ellipse
+import matplotlib.pyplot as plt
+from mpl_toolkits.axes_grid.anchored_artists import AnchoredAuxTransformBox
+
+fig=plt.figure(1, figsize=(3,3))
+ax = plt.subplot(111)
+
+box = AnchoredAuxTransformBox(ax.transData, loc=2)
+el = Ellipse((0,0), width=0.1, height=0.4, angle=30) # in data coordinates!
+box.drawing_area.add_artist(el)
+
+ax.add_artist(box)
+
+plt.show()
Added: trunk/matplotlib/doc/users/plotting/examples/anchored_box04.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/anchored_box04.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/anchored_box04.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,35 @@
+from matplotlib.patches import Ellipse
+import matplotlib.pyplot as plt
+from matplotlib.offsetbox import AnchoredOffsetbox, TextArea, DrawingArea, HPacker
+
+fig=plt.figure(1, figsize=(3,3))
+ax = plt.subplot(111)
+
+box1 = TextArea(" Test : ", textprops=dict(color="k"))
+
+box2 = DrawingArea(60, 20, 0, 0)
+el1 = Ellipse((10, 10), width=16, height=5, angle=30, fc="r")
+el2 = Ellipse((30, 10), width=16, height=5, angle=170, fc="g")
+el3 = Ellipse((50, 10), width=16, height=5, angle=230, fc="b")
+box2.add_artist(el1)
+box2.add_artist(el2)
+box2.add_artist(el3)
+
+
+box = HPacker(children=[box1, box2],
+ align="center",
+ pad=0, sep=5)
+
+anchored_box = AnchoredOffsetbox(loc=3,
+ child=box, pad=0.,
+ frameon=True,
+ bbox_to_anchor=(0., 1.02),
+ bbox_transform=ax.transAxes,
+ borderpad=0.,
+ )
+
+
+ax.add_artist(anchored_box)
+
+fig.subplots_adjust(top=0.8)
+plt.show()
Added: trunk/matplotlib/doc/users/plotting/examples/annotate_explain.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/annotate_explain.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/annotate_explain.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,103 @@
+
+import matplotlib.pyplot as plt
+import matplotlib.patches as mpatches
+
+x1, y1 = 0.3, 0.3
+x2, y2 = 0.7, 0.7
+
+fig = plt.figure(1, figsize=(8,3))
+fig.clf()
+from mpl_toolkits.axes_grid.axes_grid import AxesGrid
+from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
+
+#from matplotlib.font_manager import FontProperties
+
+def add_at(ax, t, loc=2):
+ fp = dict(size=10)
+ _at = AnchoredText(t, loc=loc, prop=fp)
+ ax.add_artist(_at)
+ return _at
+
+
+grid = AxesGrid(fig, 111, (1, 4), label_mode="1", share_all=True)
+
+grid[0].set_autoscale_on(False)
+
+ax = grid[0]
+ax.plot([x1, x2], [y1, y2], ".")
+el = mpatches.Ellipse((x1, y1), 0.3, 0.4, angle=30, alpha=0.2)
+ax.add_artist(el)
+ax.annotate("",
+ xy=(x1, y1), xycoords='data',
+ xytext=(x2, y2), textcoords='data',
+ arrowprops=dict(arrowstyle="-", #linestyle="dashed",
+ color="0.5",
+ patchB=None,
+ shrinkB=0,
+ connectionstyle="arc3,rad=0.3",
+ ),
+ )
+
+add_at(ax, "connect", loc=2)
+
+ax = grid[1]
+ax.plot([x1, x2], [y1, y2], ".")
+el = mpatches.Ellipse((x1, y1), 0.3, 0.4, angle=30, alpha=0.2)
+ax.add_artist(el)
+ax.annotate("",
+ xy=(x1, y1), xycoords='data',
+ xytext=(x2, y2), textcoords='data',
+ arrowprops=dict(arrowstyle="-", #linestyle="dashed",
+ color="0.5",
+ patchB=el,
+ shrinkB=0,
+ connectionstyle="arc3,rad=0.3",
+ ),
+ )
+
+add_at(ax, "clip", loc=2)
+
+
+ax = grid[2]
+ax.plot([x1, x2], [y1, y2], ".")
+el = mpatches.Ellipse((x1, y1), 0.3, 0.4, angle=30, alpha=0.2)
+ax.add_artist(el)
+ax.annotate("",
+ xy=(x1, y1), xycoords='data',
+ xytext=(x2, y2), textcoords='data',
+ arrowprops=dict(arrowstyle="-", #linestyle="dashed",
+ color="0.5",
+ patchB=el,
+ shrinkB=5,
+ connectionstyle="arc3,rad=0.3",
+ ),
+ )
+
+add_at(ax, "shrink", loc=2)
+
+
+ax = grid[3]
+ax.plot([x1, x2], [y1, y2], ".")
+el = mpatches.Ellipse((x1, y1), 0.3, 0.4, angle=30, alpha=0.2)
+ax.add_artist(el)
+ax.annotate("",
+ xy=(x1, y1), xycoords='data',
+ xytext=(x2, y2), textcoords='data',
+ arrowprops=dict(arrowstyle="fancy", #linestyle="dashed",
+ color="0.5",
+ patchB=el,
+ shrinkB=5,
+ connectionstyle="arc3,rad=0.3",
+ ),
+ )
+
+add_at(ax, "mutate", loc=2)
+
+grid[0].set_xlim(0, 1)
+grid[0].set_ylim(0, 1)
+grid[0].axis["bottom"].toggle(ticklabels=False)
+grid[0].axis["left"].toggle(ticklabels=False)
+fig.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95)
+
+plt.draw()
+plt.show()
Added: trunk/matplotlib/doc/users/plotting/examples/annotate_simple01.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/annotate_simple01.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/annotate_simple01.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,14 @@
+import matplotlib.pyplot as plt
+
+plt.figure(1, figsize=(3,3))
+ax = plt.subplot(111)
+
+ax.annotate("",
+ xy=(0.2, 0.2), xycoords='data',
+ xytext=(0.8, 0.8), textcoords='data',
+ arrowprops=dict(arrowstyle="->",
+ connectionstyle="arc3"),
+ )
+
+plt.show()
+
Added: trunk/matplotlib/doc/users/plotting/examples/annotate_simple02.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/annotate_simple02.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/annotate_simple02.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,15 @@
+import matplotlib.pyplot as plt
+
+plt.figure(1, figsize=(3,3))
+ax = plt.subplot(111)
+
+ax.annotate("Test",
+ xy=(0.2, 0.2), xycoords='data',
+ xytext=(0.8, 0.8), textcoords='data',
+ size=20, va="center", ha="center",
+ arrowprops=dict(arrowstyle="simple",
+ connectionstyle="arc3,rad=-0.2"),
+ )
+
+plt.show()
+
Added: trunk/matplotlib/doc/users/plotting/examples/annotate_simple03.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/annotate_simple03.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/annotate_simple03.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,17 @@
+import matplotlib.pyplot as plt
+
+plt.figure(1, figsize=(3,3))
+ax = plt.subplot(111)
+
+ann = ax.annotate("Test",
+ xy=(0.2, 0.2), xycoords='data',
+ xytext=(0.8, 0.8), textcoords='data',
+ size=20, va="center", ha="center",
+ bbox=dict(boxstyle="round4", fc="w"),
+ arrowprops=dict(arrowstyle="-|>",
+ connectionstyle="arc3,rad=-0.2",
+ fc="w"),
+ )
+
+plt.show()
+
Added: trunk/matplotlib/doc/users/plotting/examples/annotate_simple04.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/annotate_simple04.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/annotate_simple04.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,29 @@
+import matplotlib.pyplot as plt
+
+plt.figure(1, figsize=(3,3))
+ax = plt.subplot(111)
+
+ann = ax.annotate("Test",
+ xy=(0.2, 0.2), xycoords='data',
+ xytext=(0.8, 0.8), textcoords='data',
+ size=20, va="center", ha="center",
+ bbox=dict(boxstyle="round4", fc="w"),
+ arrowprops=dict(arrowstyle="-|>",
+ connectionstyle="arc3,rad=0.2",
+ relpos=(0., 0.),
+ fc="w"),
+ )
+
+ann = ax.annotate("Test",
+ xy=(0.2, 0.2), xycoords='data',
+ xytext=(0.8, 0.8), textcoords='data',
+ size=20, va="center", ha="center",
+ bbox=dict(boxstyle="round4", fc="w"),
+ arrowprops=dict(arrowstyle="-|>",
+ connectionstyle="arc3,rad=-0.2",
+ relpos=(1., 0.),
+ fc="w"),
+ )
+
+plt.show()
+
Added: trunk/matplotlib/doc/users/plotting/examples/annotate_text_arrow.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/annotate_text_arrow.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/annotate_text_arrow.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,38 @@
+
+import numpy.random
+import matplotlib.pyplot as plt
+
+fig = plt.figure(1, figsize=(5,5))
+fig.clf()
+
+ax = fig.add_subplot(111)
+ax.set_aspect(1)
+
+x1 = -1 + numpy.random.randn(100)
+y1 = -1 + numpy.random.randn(100)
+x2 = 1. + numpy.random.randn(100)
+y2 = 1. + numpy.random.randn(100)
+
+ax.scatter(x1, y1, color="r")
+ax.scatter(x2, y2, color="g")
+
+bbox_props = dict(boxstyle="round", fc="w", ec="0.5", alpha=0.9)
+ax.text(-2, -2, "Sample A", ha="center", va="center", size=20,
+ bbox=bbox_props)
+ax.text(2, 2, "Sample B", ha="center", va="center", size=20,
+ bbox=bbox_props)
+
+
+bbox_props = dict(boxstyle="rarrow", fc=(0.8,0.9,0.9), ec="b", lw=2)
+t = ax.text(0, 0, "Direction", ha="center", va="center", rotation=45,
+ size=15,
+ bbox=bbox_props)
+
+bb = t.get_bbox_patch()
+bb.set_boxstyle("rarrow", pad=0.6)
+
+ax.set_xlim(-4, 4)
+ax.set_ylim(-4, 4)
+
+plt.draw()
+plt.show()
Added: trunk/matplotlib/doc/users/plotting/examples/axes_zoom_effect.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/axes_zoom_effect.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/axes_zoom_effect.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1 @@
+../../../../examples/pylab_examples/axes_zoom_effect.py
\ No newline at end of file
Added: trunk/matplotlib/doc/users/plotting/examples/connect_simple01.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/connect_simple01.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/connect_simple01.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,31 @@
+from matplotlib.patches import ConnectionPatch
+import matplotlib.pyplot as plt
+
+fig = plt.figure(1, figsize=(6,3))
+ax1 = plt.subplot(121)
+xyA=(0.2, 0.2)
+xyB=(0.8, 0.8)
+coordsA="data"
+coordsB="data"
+con = ConnectionPatch(xyA, xyB, coordsA, coordsB,
+ arrowstyle="-|>", shrinkA=5, shrinkB=5,
+ mutation_scale=20, fc="w")
+ax1.plot([xyA[0], xyB[0]], [xyA[1], xyB[1]], "o")
+ax1.add_artist(con)
+
+ax2 = plt.subplot(122)
+#xyA=(0.7, 0.7)
+xy=(0.3, 0.2)
+coordsA="data"
+coordsB="data"
+con = ConnectionPatch(xyA=xy, xyB=xy, coordsA=coordsA, coordsB=coordsB,
+ axesA=ax2, axesB=ax1,
+ arrowstyle="->", shrinkB=5)
+ax2.add_artist(con)
+
+ax1.set_xlim(0, 1)
+ax1.set_ylim(0, 1)
+ax2.set_xlim(0, .5)
+ax2.set_ylim(0, .5)
+plt.draw()
+plt.show()
Added: trunk/matplotlib/doc/users/plotting/examples/connectionstyle_demo.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/connectionstyle_demo.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/connectionstyle_demo.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,109 @@
+
+import matplotlib.pyplot as plt
+import matplotlib.patches as mpatches
+
+fig = plt.figure(1, figsize=(8,5))
+fig.clf()
+from mpl_toolkits.axes_grid.axes_grid import AxesGrid
+from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
+
+#from matplotlib.font_manager import FontProperties
+
+def add_at(ax, t, loc=2):
+ fp = dict(size=8)
+ _at = AnchoredText(t, loc=loc, prop=fp)
+ ax.add_artist(_at)
+ return _at
+
+
+grid = AxesGrid(fig, 111, (3, 5), label_mode="1", share_all=True)
+
+grid[0].set_autoscale_on(False)
+
+
+x1, y1 = 0.3, 0.3
+x2, y2 = 0.7, 0.7
+
+
+def demo_con_style(ax, connectionstyle, label=None):
+
+ if label is None:
+ label = connectionstyle
+
+ x1, y1 = 0.3, 0.2
+ x2, y2 = 0.8, 0.6
+
+ ax.plot([x1, x2], [y1, y2], ".")
+ ax.annotate("",
+ xy=(x1, y1), xycoords='data',
+ xytext=(x2, y2), textcoords='data',
+ arrowprops=dict(arrowstyle="->", #linestyle="dashed",
+ color="0.5",
+ shrinkA=5, shrinkB=5,
+ patchA=None,
+ patchB=None,
+ connectionstyle=connectionstyle,
+ ),
+ )
+
+ add_at(ax, label, loc=2)
+
+column = grid.axes_column[0]
+
+demo_con_style(column[0], "angle3,angleA=90,angleB=0",
+ label="angle3,\nangleA=90,\nangleB=0")
+demo_con_style(column[1], "angle3,angleA=0,angleB=90",
+ label="angle3,\nangleA=0,\nangleB=90")
+
+
+
+column = grid.axes_column[1]
+
+demo_con_style(column[0], "arc3,rad=0.")
+demo_con_style(column[1], "arc3,rad=0.3")
+demo_con_style(column[2], "arc3,rad=-0.3")
+
+
+
+column = grid.axes_column[2]
+
+demo_con_style(column[0], "angle,angleA=-90,angleB=180,rad=0",
+ label="angle,\nangleA=-90,\nangleB=180,\nrad=0")
+demo_con_style(column[1], "angle,angleA=-90,angleB=180,rad=5",
+ label="angle,\nangleA=-90,\nangleB=180,\nrad=5")
+demo_con_style(column[2], "angle,angleA=-90,angleB=10,rad=5",
+ label="angle,\nangleA=-90,\nangleB=10,\nrad=0")
+
+
+column = grid.axes_column[3]
+
+demo_con_style(column[0], "arc,angleA=-90,angleB=0,armA=30,armB=30,rad=0",
+ label="arc,\nangleA=-90,\nangleB=0,\narmA=30,\narmB=30,\nrad=0")
+demo_con_style(column[1], "arc,angleA=-90,angleB=0,armA=30,armB=30,rad=5",
+ label="arc,\nangleA=-90,\nangleB=0,\narmA=30,\narmB=30,\nrad=5")
+demo_con_style(column[2], "arc,angleA=-90,angleB=0,armA=0,armB=40,rad=0",
+ label="arc,\nangleA=-90,\nangleB=0,\narmA=0,\narmB=40,\nrad=0")
+
+
+column = grid.axes_column[4]
+
+demo_con_style(column[0], "bar,fraction=0.3",
+ label="bar,\nfraction=0.3")
+demo_con_style(column[1], "bar,fraction=-0.3",
+ label="bar,\nfraction=-0.3")
+demo_con_style(column[2], "bar,angle=180,fraction=-0.2",
+ label="bar,\nangle=180,\nfraction=-0.2")
+
+
+#demo_con_style(column[1], "arc3,rad=0.3")
+#demo_con_style(column[2], "arc3,rad=-0.3")
+
+
+grid[0].set_xlim(0, 1)
+grid[0].set_ylim(0, 1)
+grid.axes_llc.axis["bottom"].toggle(ticklabels=False)
+grid.axes_llc.axis["left"].toggle(ticklabels=False)
+fig.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95)
+
+plt.draw()
+plt.show()
Added: trunk/matplotlib/doc/users/plotting/examples/custom_boxstyle01.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/custom_boxstyle01.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/custom_boxstyle01.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,47 @@
+from matplotlib.path import Path
+
+def custom_box_style(x0, y0, width, height, mutation_size, mutation_aspect=1):
+ """
+ Given the location and size of the box, return the path of
+ the box around it.
+
+ - *x0*, *y0*, *width*, *height* : location and size of the box
+ - *mutation_size* : a reference scale for the mutation.
+ - *aspect_ratio* : aspect-ration for the mutation.
+ """
+
+ # note that we are ignoring mutation_aspect. This is okay in general.
+
+ # padding
+ mypad = 0.3
+ pad = mutation_size * mypad
+
+ # width and height with padding added.
+ width, height = width + 2.*pad, \
+ height + 2.*pad,
+
+ # boundary of the padded box
+ x0, y0 = x0-pad, y0-pad,
+ x1, y1 = x0+width, y0 + height
+
+ cp = [(x0, y0),
+ (x1, y0), (x1, y1), (x0, y1),
+ (x0-pad, (y0+y1)/2.), (x0, y0),
+ (x0, y0)]
+
+ com = [Path.MOVETO,
+ Path.LINETO, Path.LINETO, Path.LINETO,
+ Path.LINETO, Path.LINETO,
+ Path.CLOSEPOLY]
+
+ path = Path(cp, com)
+
+ return path
+
+
+import matplotlib.pyplot as plt
+
+plt.figure(1, figsize=(3,3))
+ax = plt.subplot(111)
+ax.text(0.5, 0.5, "Test", size=30, va="center", ha="center",
+ bbox=dict(boxstyle=custom_box_style, alpha=0.2))
Added: trunk/matplotlib/doc/users/plotting/examples/custom_boxstyle02.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/custom_boxstyle02.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/custom_boxstyle02.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,74 @@
+from matplotlib.path import Path
+from matplotlib.patches import BoxStyle
+import matplotlib.pyplot as plt
+
+# we may derive from matplotlib.patches.BoxStyle._Base class.
+# You need to overide transmute method in this case.
+
+class MyStyle(BoxStyle._Base):
+ """
+ A simple box.
+ """
+
+ def __init__(self, pad=0.3):
+ """
+ The arguments need to be floating numbers and need to have
+ default values.
+
+ *pad*
+ amount of padding
+ """
+
+ self.pad = pad
+ super(MyStyle, self).__init__()
+
+ def transmute(self, x0, y0, width, height, mutation_size):
+ """
+ Given the location and size of the box, return the path of
+ the box around it.
+
+ - *x0*, *y0*, *width*, *height* : location and size of the box
+ - *mutation_size* : a reference scale for the mutation.
+
+ Often, the *mutation_size* is the font size of the text.
+ You don't need to worry about the rotation as it is
+ automatically taken care of.
+ """
+
+ # padding
+ pad = mutation_size * self.pad
+
+ # width and height with padding added.
+ width, height = width + 2.*pad, \
+ height + 2.*pad,
+
+ # boundary of the padded box
+ x0, y0 = x0-pad, y0-pad,
+ x1, y1 = x0+width, y0 + height
+
+ cp = [(x0, y0),
+ (x1, y0), (x1, y1), (x0, y1),
+ (x0-pad, (y0+y1)/2.), (x0, y0),
+ (x0, y0)]
+
+ com = [Path.MOVETO,
+ Path.LINETO, Path.LINETO, Path.LINETO,
+ Path.LINETO, Path.LINETO,
+ Path.CLOSEPOLY]
+
+ path = Path(cp, com)
+
+ return path
+
+
+# register the custom style
+BoxStyle._style_list["angled"] = MyStyle
+
+plt.figure(1, figsize=(3,3))
+ax = plt.subplot(111)
+ax.text(0.5, 0.5, "Test", size=30, va="center", ha="center", rotation=30,
+ bbox=dict(boxstyle="angled,pad=0.5", alpha=0.2))
+
+del BoxStyle._style_list["angled"]
+
+plt.show()
Added: trunk/matplotlib/doc/users/plotting/examples/simple_annotate01.py
===================================================================
--- trunk/matplotlib/doc/users/plotting/examples/simple_annotate01.py (rev 0)
+++ trunk/matplotlib/doc/users/plotting/examples/simple_annotate01.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,131 @@
+
+import matplotlib.pyplot as plt
+import matplotlib.patches as mpatches
+
+x1, y1 = 0.3, 0.3
+x2, y2 = 0.7, 0.7
+
+fig = plt.figure(1)
+fig.clf()
+from mpl_toolkits.axes_grid.axes_grid import Grid
+from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
+
+from matplotlib.font_manager import FontProperties
+
+def add_at(ax, t, loc=2):
+ fp = dict(size=10)
+ _at = AnchoredText(t, loc=loc, prop=fp)
+ ax.add_artist(_at)
+ return _at
+
+
+grid = Grid(fig, 111, (4, 4), label_mode="1", share_all=True)
+
+grid[0].set_autoscale_on(False)
+
+ax = grid[0]
+ax.plot([x1, x2], [y1, y2], "o")
+ax.annotate("",
+ xy=(x1, y1), xycoords='data',
+ xytext=(x2, y2), textcoords='data',
+ arrowprops=dict(arrowstyle="->"))
+
+add_at(ax, "A $->$ B", loc=2)
+
+ax = grid[1]
+ax.plot([x1, x2], [y1, y2], "o")
+ax.annotate("",
+ xy=(x1, y1), xycoords='data',
+ xytext=(x2, y2), textcoords='data',
+ arrowprops=dict(arrowstyle="->",
+ connectionstyle="arc3,rad=0.3"))
+
+add_at(ax, "connectionstyle=arc3", loc=2)
+
+
+ax = grid[2]
+ax.plot([x1, x2], [y1, y2], "o")
+ax.annotate("",
+ xy=(x1, y1), xycoords='data',
+ xytext=(x2, y2), textcoords='data',
+ arrowprops=dict(arrowstyle="->",
+ connectionstyle="arc3,rad=0.3",
+ shrinkB=5,
+ )
+ )
+
+add_at(ax, "shrinkB=5", loc=2)
+
+
+ax = grid[3]
+ax.plot([x1, x2], [y1, y2], "o")
+el = mpatches.Ellipse((x1, y1), 0.3, 0.4, angle=30, alpha=0.5)
+ax.add_artist(el)
+ax.annotate("",
+ xy=(x1, y1), xycoords='data',
+ xytext=(x2, y2), textcoords='data',
+ arrowprops=dict(arrowstyle="->",
+ connectionstyle="arc3,rad=0.2",
+ )
+ )
+
+
+ax = grid[4]
+ax.plot([x1, x2], [y1, y2], "o")
+el = mpatches.Ellipse((x1, y1), 0.3, 0.4, angle=30, alpha=0.5)
+ax.add_artist(el)
+ax.annotate("",
+ xy=(x1, y1), xycoords='data',
+ xytext=(x2, y2), textcoords='data',
+ arrowprops=dict(arrowstyle="->",
+ connectionstyle="arc3,rad=0.2",
+ patchB=el,
+ )
+ )
+
+
+add_at(ax, "patchB", loc=2)
+
+
+
+ax = grid[5]
+ax.plot([x1], [y1], "o")
+ax.annotate("Test",
+ xy=(x1, y1), xycoords='data',
+ xytext=(x2, y2), textcoords='data',
+ ha="center", va="center",
+ bbox=dict(boxstyle="round",
+ fc="w",
+ ),
+ arrowprops=dict(arrowstyle="->",
+ #connectionstyle="arc3,rad=0.2",
+ )
+ )
+
+
+add_at(ax, "annotate", loc=2)
+
+
+ax = grid[6]
+ax.plot([x1], [y1], "o")
+ax.annotate("Test",
+ xy=(x1, y1), xycoords='data',
+ xytext=(x2, y2), textcoords='data',
+ ha="center", va="center",
+ bbox=dict(boxstyle="round",
+ fc="w",
+ ),
+ arrowprops=dict(arrowstyle="->",
+ #connectionstyle="arc3,rad=0.2",
+ relpos=(0., 0.)
+ )
+ )
+
+
+add_at(ax, "relpos=(0,0)", loc=2)
+
+
+
+#ax.set_xlim(0, 1)
+#ax.set_ylim(0, 1)
+plt.draw()
Modified: trunk/matplotlib/doc/users/plotting.rst
===================================================================
--- trunk/matplotlib/doc/users/plotting.rst 2009-07-14 21:18:58 UTC (rev 7261)
+++ trunk/matplotlib/doc/users/plotting.rst 2009-07-14 21:24:07 UTC (rev 7262)
@@ -146,5 +146,11 @@
:ref:`plotting-guide-legend`
+Annotating plot
+===============
+:func:`~matplotlib.pyplot.text` and :func:`~matplotlib.pyplot.annotate`
+
+:ref:`plotting-guide-annotation`
+
TODO; see :ref:`how-to-contribute-docs`.
Added: trunk/matplotlib/examples/pylab_examples/axes_zoom_effect.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/axes_zoom_effect.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/axes_zoom_effect.py 2009-07-14 21:24:07 UTC (rev 7262)
@@ -0,0 +1,120 @@
+from matplotlib.transforms import Bbox, TransformedBbox, \
+ blended_transform_factory
+
+from mpl_toolkits.axes_grid.inset_locator import BboxPatch, BboxConnector,\
+ BboxConnectorPatch
+
+
+def connect_bbox(bbox1, bbox2,
+ loc1a, loc2a, loc1b, loc2b,
+ prop_lines, prop_patches=None):
+ if prop_patches is None:
+ prop_patches = prop_lines.copy()
+ prop_patches["alpha"] = prop_patches.get("alpha", 1)*0.2
+
+ c1 = BboxConnector(bbox1, bbox2, loc1=loc1a, loc2=loc2a, **prop_lines)
+ c1.set_clip_on(False)
+ c2 = BboxConnector(bbox1, bbox2, loc1=loc1b, loc2=loc2b, **prop_lines)
+ c2.set_clip_on(False)
+
+ bbox_patch1 = BboxPatch(bbox1, **prop_patches)
+ bbox_patch2 = BboxPatch(bbox2, **prop_patches)
+
+ p = BboxConnectorPatch(bbox1, bbox2,
+ #loc1a=3, loc2a=2, loc1b=4, loc2b=1,
+ loc1a=loc1a, loc2a=loc2a, loc1b=loc1b, loc2b=loc2b,
+ **prop_patches)
+ p.set_clip_on(False)
+
+ return c1, c2, bbox_patch1, bbox_patch2, p
+
+
+def zoom_effect01(ax1, ax2, xmin, xmax, **kwargs):
+ u"""
+ ax1 : the main axes
+ ax1 : the zoomed axes
+ (xmin,xmax) : the limits of the colored area in both plot axes.
+
+ connect ax1 & ax2. The x-range of (xmin, xmax) in both axes will
+ be marked. The keywords parameters will be used ti create
+ patches.
+
+ """
+
+ trans1 = blended_transform_factory(ax1.transData, ax1.transAxes)
+ trans2 = blended_transform_factory(ax2.transData, ax2.transAxes)
+
+ bbox = Bbox.from_extents(xmin, 0, xmax, 1)
+
+ mybbox1 = TransformedBbox(bbox, trans1)
+ mybbox2 = TransformedBbox(bbox, trans2)
+
+ prop_patches=kwargs.copy()
+ prop_patches["ec"]="none"
+ prop_patches["alpha"]="0.2"
+
+ c1, c2, bbox_patch1, bbox_patch2, p = \
+ connect_bbox(mybbox1, mybbox2,
+ loc1a=3, loc2a=2, loc1b=4, loc2b=1,
+ prop_lines=kwargs, prop_patches=prop_patches)
+
+ ax1.add_patch(bbox_patch1)
+ ax2.add_patch(bbox_patch2)
+ ax2.add_patch(c1)
+ ax2.add_patch(c2)
+ ax2.add_patch(p)
+
+ return c1, c2, bbox_patch1, bbox_patch2, p
+
+
+def zoom_effect02(ax1, ax2, **kwargs):
+ u"""
+ ax1 : the main axes
+ ax1 : the zoomed axes
+
+ Similar to zoom_effect01. The xmin & xmax will be taken from the
+ ax1.viewLim.
+ """
+
+ tt = ax1.transScale + (ax1.transLimits + ax2.transAxes)
+ trans = blended_transform_factory(ax2.transData, tt)
+
+ mybbox1 = ax1.bbox
+ mybbox2 = TransformedBbox(ax1.viewLim, trans)
+
+ prop_patches=kwargs.copy()
+ prop_patches["ec"]="none"
+ prop_patches["alpha"]="0.2"
+
+ c1, c2, bbox_patch1, bbox_patch2, p = \
+ connect_bbox(mybbox1, mybbox2,
+ loc1a=3, loc2a=2, loc1b=4, loc2b=1,
+ prop_lines=kwargs, prop_patches=prop_patches)
+
+ ax1.add_patch(bbox_patch1)
+ ax2.add_patch(bbox_patch2)
+ ax2.add_patch(c1)
+ ax2.add_patch(c2)
+ ax2.add_patch(p)
+
+ return c1, c2, bbox_patch1, bbox_patch2, p
+
+
+if __name__ == "__main__":
+ import matplotlib.pyplot as plt
+
+ plt.figure(1, figsize=(5,5))
+ ax1 = plt.subplot(221)
+ ax2 = plt.subplot(212)
+ ax2.set_xlim(0, 1)
+ ax2.set_xlim(0, 5)
+ zoom_effect01(ax1, ax2, 0.2, 0.8)
+
+
+ ax1 = plt.subplot(222)
+ ax1.set_xlim(2, 3)
+ ax2.set_xlim(0, 5)
+ zoom_effect02(ax1, ax2)
+
+ plt.show()
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-07-14 21:19:01
|
Revision: 7261
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7261&view=rev
Author: leejjoon
Date: 2009-07-14 21:18:58 +0000 (Tue, 14 Jul 2009)
Log Message:
-----------
axes_grid : minor improvements in anchored_artists and inset_locator.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/mpl_toolkits/axes_grid/__init__.py
trunk/matplotlib/lib/mpl_toolkits/axes_grid/anchored_artists.py
trunk/matplotlib/lib/mpl_toolkits/axes_grid/axes_grid.py
trunk/matplotlib/lib/mpl_toolkits/axes_grid/inset_locator.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-07-14 21:11:53 UTC (rev 7260)
+++ trunk/matplotlib/CHANGELOG 2009-07-14 21:18:58 UTC (rev 7261)
@@ -1,3 +1,6 @@
+2009-07-14 axes_grid : minor improvements in anchored_artists and
+ inset_locator. -JJL
+
2009-07-14 Fix a few bugs in ConnectionStyle algorithms. Add
ConnectionPatch class. -JJL
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/__init__.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/__init__.py 2009-07-14 21:11:53 UTC (rev 7260)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/__init__.py 2009-07-14 21:18:58 UTC (rev 7261)
@@ -1,10 +1,6 @@
-"""
-AxesGrid
-"""
-
import axes_size as Size
from axes_divider import Divider, SubplotDivider, LocatableAxes, \
make_axes_locatable
-from axes_grid import AxesGrid
+from axes_grid import Grid, ImageGrid, AxesGrid
#from axes_divider import make_axes_locatable
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/anchored_artists.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/anchored_artists.py 2009-07-14 21:11:53 UTC (rev 7260)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/anchored_artists.py 2009-07-14 21:18:58 UTC (rev 7261)
@@ -21,34 +21,37 @@
**kwargs)
-class AnchoredSizeBar(AnchoredOffsetbox):
- def __init__(self, transform, size, label, loc,
- pad=0.1, borderpad=0.1, sep=2, prop=None, frameon=True):
- """
- Draw a horizontal bar with the size in data coordinate of the give axes.
- A label will be drawn underneath (center-alinged).
- pad, borderpad in fraction of the legend font size (or prop)
- sep in points.
- """
- self.size_bar = AuxTransformBox(transform)
- self.size_bar.add_artist(Rectangle((0,0), size, 0, fc="none"))
+class AnchoredDrawingArea(AnchoredOffsetbox):
+ def __init__(self, width, height, xdescent, ydescent,
+ loc, pad=0.4, borderpad=0.5, prop=None, frameon=True,
+ **kwargs):
- self.txt_label = TextArea(label, minimumdescent=False)
+ self.da = DrawingArea(width, height, xdescent, ydescent, clip=True)
+ self.drawing_area = self.da
+
+ super(AnchoredDrawingArea, self).__init__(loc, pad=pad, borderpad=borderpad,
+ child=self.da,
+ prop=None,
+ frameon=frameon,
+ **kwargs)
- self._box = VPacker(children=[self.size_bar, self.txt_label],
- align="center",
- pad=0, sep=sep)
+class AnchoredAuxTransformBox(AnchoredOffsetbox):
+ def __init__(self, transform, loc,
+ pad=0.4, borderpad=0.5, prop=None, frameon=True, **kwargs):
+ self.drawing_area = AuxTransformBox(transform)
+
AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad,
- child=self._box,
+ child=self.drawing_area,
prop=prop,
- frameon=frameon)
+ frameon=frameon,
+ **kwargs)
class AnchoredEllipse(AnchoredOffsetbox):
def __init__(self, transform, width, height, angle, loc,
- pad=0.1, borderpad=0.1, prop=None, frameon=True):
+ pad=0.1, borderpad=0.1, prop=None, frameon=True, **kwargs):
"""
Draw an ellipse the size in data coordinate of the give axes.
@@ -61,20 +64,32 @@
AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad,
child=self._box,
prop=prop,
- frameon=frameon)
+ frameon=frameon, **kwargs)
-class AnchoredDrawingArea(AnchoredOffsetbox):
- def __init__(self, width, height, xdescent, ydescent,
- loc, pad=0.4, borderpad=0.5, prop=None, frameon=True):
+class AnchoredSizeBar(AnchoredOffsetbox):
+ def __init__(self, transform, size, label, loc,
+ pad=0.1, borderpad=0.1, sep=2, prop=None, frameon=True,
+ **kwargs):
+ """
+ Draw a horizontal bar with the size in data coordinate of the give axes.
+ A label will be drawn underneath (center-alinged).
- self.da = DrawingArea(width, height, xdescent, ydescent, clip=True)
+ pad, borderpad in fraction of the legend font size (or prop)
+ sep in points.
+ """
+ self.size_bar = AuxTransformBox(transform)
+ self.size_bar.add_artist(Rectangle((0,0), size, 0, fc="none"))
- super(AnchoredDrawingArea, self).__init__(loc, pad=pad, borderpad=borderpad,
- child=self.da,
- prop=None,
- frameon=frameon)
+ self.txt_label = TextArea(label, minimumdescent=False)
+ self._box = VPacker(children=[self.size_bar, self.txt_label],
+ align="center",
+ pad=0, sep=sep)
+ AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad,
+ child=self._box,
+ prop=prop,
+ frameon=frameon, **kwargs)
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/axes_grid.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/axes_grid.py 2009-07-14 21:11:53 UTC (rev 7260)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/axes_grid.py 2009-07-14 21:18:58 UTC (rev 7261)
@@ -168,7 +168,7 @@
axes_class=None,
):
"""
- Build an :class:`AxesGrid` instance with a grid nrows*ncols
+ Build an :class:`Grid` instance with a grid nrows*ncols
:class:`~matplotlib.axes.Axes` in
:class:`~matplotlib.figure.Figure` *fig* with
*rect=[left, bottom, width, height]* (in
@@ -184,7 +184,8 @@
axes_pad 0.02 float| pad betweein axes given in inches
add_all True [ True | False ]
share_all False [ True | False ]
- aspect True [ True | False ]
+ share_x True [ True | False ]
+ share_y True [ True | False ]
label_mode "L" [ "L" | "1" | "all" ]
axes_class None a type object which must be a subclass
of :class:`~matplotlib.axes.Axes`
@@ -406,14 +407,14 @@
_tick_only(ax, bottom_on=False, left_on=False)
-class AxesGrid(Grid):
+class ImageGrid(Grid):
"""
A class that creates a grid of Axes. In matplotlib, the axes
location (and size) is specified in the normalized figure
coordinates. This may not be ideal for images that needs to be
displayed with a given aspect ratio. For example, displaying
images of a same size with some fixed padding between them cannot
- be easily done in matplotlib. AxesGrid is used in such case.
+ be easily done in matplotlib. ImageGrid is used in such case.
"""
def __init__(self, fig,
@@ -433,7 +434,7 @@
axes_class=None,
):
"""
- Build an :class:`AxesGrid` instance with a grid nrows*ncols
+ Build an :class:`ImageGrid` instance with a grid nrows*ncols
:class:`~matplotlib.axes.Axes` in
:class:`~matplotlib.figure.Figure` *fig* with
*rect=[left, bottom, width, height]* (in
@@ -661,6 +662,7 @@
self._divider.set_vertical(v)
+AxesGrid = ImageGrid
@@ -689,7 +691,7 @@
F.subplots_adjust(left=0.05, right=0.98)
- grid = AxesGrid(F, 131, # similar to subplot(111)
+ grid = ImageGrid(F, 131, # similar to subplot(111)
nrows_ncols = (2, 2),
direction="row",
axes_pad = 0.05,
@@ -708,7 +710,7 @@
plt.ion()
- grid = AxesGrid(F, 132, # similar to subplot(111)
+ grid = ImageGrid(F, 132, # similar to subplot(111)
nrows_ncols = (2, 2),
direction="row",
axes_pad = 0.0,
@@ -733,7 +735,7 @@
- grid = AxesGrid(F, 133, # similar to subplot(122)
+ grid = ImageGrid(F, 133, # similar to subplot(122)
nrows_ncols = (2, 2),
direction="row",
axes_pad = 0.1,
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/inset_locator.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/inset_locator.py 2009-07-14 21:11:53 UTC (rev 7260)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/inset_locator.py 2009-07-14 21:18:58 UTC (rev 7261)
@@ -239,6 +239,23 @@
self.loc1, self.loc2)
+class BboxConnectorPatch(BboxConnector):
+
+ def __init__(self, bbox1, bbox2, loc1a, loc2a, loc1b, loc2b, **kwargs):
+ if "transform" in kwargs:
+ raise ValueError("transform should not be set")
+ BboxConnector.__init__(self, bbox1, bbox2, loc1a, loc2a, **kwargs)
+ self.loc1b = loc1b
+ self.loc2b = loc2b
+
+ def get_path(self):
+ path1 = self.connect_bbox(self.bbox1, self.bbox2, self.loc1, self.loc2)
+ path2 = self.connect_bbox(self.bbox2, self.bbox1, self.loc2b, self.loc1b)
+ path_merged = list(path1.vertices) + list (path2.vertices) + [path1.vertices[0]]
+ return Path(path_merged)
+
+
+
def _add_inset_axes(parent_axes, inset_axes):
parent_axes.figure.add_axes(inset_axes)
inset_axes.set_navigate(False)
@@ -285,7 +302,9 @@
inset_axes = axes_class(parent_axes.figure, parent_axes.get_position(),
**axes_kwargs)
- axes_locator = AnchoredZoomLocator(parent_axes, zoom=zoom, loc=loc)
+ axes_locator = AnchoredZoomLocator(parent_axes, zoom=zoom, loc=loc,
+ bbox_to_anchor=None, bbox_transform=None,
+ **kwargs)
inset_axes.set_axes_locator(axes_locator)
_add_inset_axes(parent_axes, inset_axes)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2009-07-14 21:11:59
|
Revision: 7260
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7260&view=rev
Author: heeres
Date: 2009-07-14 21:11:53 +0000 (Tue, 14 Jul 2009)
Log Message:
-----------
Fix mplot3d bug with empty lists
thanks to Ryan Wagner.
Modified Paths:
--------------
trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py
Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2009-07-14 19:21:47 UTC (rev 7259)
+++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2009-07-14 21:11:53 UTC (rev 7260)
@@ -633,11 +633,14 @@
shade = np.array(shade)
mask = ~np.isnan(shade)
- norm = Normalize(min(shade[mask]), max(shade[mask]))
- color = color.copy()
- color[3] = 1
- colors = [color * (0.5 + norm(v) * 0.5) for v in shade]
+ if len(shade[mask]) > 0:
+ norm = Normalize(min(shade[mask]), max(shade[mask]))
+ color = color.copy()
+ color[3] = 1
+ colors = [color * (0.5 + norm(v) * 0.5) for v in shade]
+ else:
+ colors = color.copy()
return colors
@@ -707,6 +710,12 @@
polyverts = []
normals = []
nsteps = round(len(topverts[0]) / stride)
+ if nsteps <= 1:
+ if len(topverts[0]) > 1:
+ nsteps = 2
+ else:
+ continue
+
stepsize = (len(topverts[0]) - 1) / (nsteps - 1)
for i in range(int(round(nsteps)) - 1):
i1 = int(round(i * stepsize))
@@ -719,11 +728,11 @@
v1 = np.array(topverts[0][i1]) - np.array(topverts[0][i2])
v2 = np.array(topverts[0][i1]) - np.array(botverts[0][i1])
normals.append(np.cross(v1, v2))
-
+
colors = self._shade_colors(color, normals)
colors2 = self._shade_colors(color, normals)
polycol = art3d.Poly3DCollection(polyverts, facecolors=colors,
- edgecolors=colors2)
+ edgecolors=colors2)
self.add_collection3d(polycol)
for col in colls:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-07-14 19:22:01
|
Revision: 7259
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7259&view=rev
Author: leejjoon
Date: 2009-07-14 19:21:47 +0000 (Tue, 14 Jul 2009)
Log Message:
-----------
Fix a few bugs in ConnectionStyle classes. Add ConnectionPatch.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/patches.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-07-12 03:20:53 UTC (rev 7258)
+++ trunk/matplotlib/CHANGELOG 2009-07-14 19:21:47 UTC (rev 7259)
@@ -1,3 +1,6 @@
+2009-07-14 Fix a few bugs in ConnectionStyle algorithms. Add
+ ConnectionPatch class. -JJL
+
2009-07-11 Added a fillstyle Line2D property for half filled markers
-- see examples/pylab_examples/fillstyle_demo.py JDH
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py 2009-07-12 03:20:53 UTC (rev 7258)
+++ trunk/matplotlib/lib/matplotlib/patches.py 2009-07-14 19:21:47 UTC (rev 7259)
@@ -1729,8 +1729,8 @@
"""
def __init__(self, pad=0.3):
- self.pad = pad
- super(BoxStyle.RArrow, self).__init__()
+ #self.pad = pad
+ super(BoxStyle.RArrow, self).__init__(pad)
def transmute(self, x0, y0, width, height, mutation_size):
@@ -2466,7 +2466,7 @@
cosA, sinA = math.cos(self.angleA/180.*math.pi),\
math.sin(self.angleA/180.*math.pi),
cosB, sinB = math.cos(self.angleB/180.*math.pi),\
- -math.sin(self.angleB/180.*math.pi),
+ math.sin(self.angleB/180.*math.pi),
cx, cy = get_intersection(x1, y1, cosA, sinA,
x2, y2, cosB, sinB)
@@ -2478,9 +2478,15 @@
vertices.append((cx, cy))
codes.append(Path.LINETO)
else:
- vertices.extend([(cx - self.rad * cosA, cy - self.rad * sinA),
+ dx1, dy1 = x1-cx, y1-cy
+ d1 = (dx1**2 + dy1**2)**.5
+ f1 = self.rad/d1
+ dx2, dy2 = x2-cx, y2-cy
+ d2 = (dx2**2 + dy2**2)**.5
+ f2 = self.rad/d2
+ vertices.extend([(cx + dx1*f1, cy + dy1*f1),
(cx, cy),
- (cx + self.rad * cosB, cy + self.rad * sinB)])
+ (cx + dx2*f2, cy + dy2*f2)])
codes.extend([Path.LINETO, Path.CURVE3, Path.CURVE3])
vertices.append((x2, y2))
@@ -2623,7 +2629,8 @@
#angle = self.angle % 180.
#if angle < 0. or angle > 180.:
# angle
- theta0 = (self.angle%180.)/180.*math.pi
+ #theta0 = (self.angle%180.)/180.*math.pi
+ theta0 = self.angle/180.*math.pi
#theta0 = (((self.angle+90)%180.) - 90.)/180.*math.pi
dtheta = theta1 - theta0
dl = dd*math.sin(dtheta)
@@ -3744,3 +3751,302 @@
gc.restore()
renderer.close_group('patch')
+
+
+class ConnectionPatch(FancyArrowPatch):
+ """
+ A :class:`~matplotlib.patches.ConnectionPatch` class is to make
+ connecting lines between two points (possibly in different axes).
+ """
+ def __str__(self):
+ return "ConnectionPatch((%g,%g),(%g,%g))" % \
+ (self.xy1[0],self.xy1[1],self.xy2[0],self.xy2[1])
+
+ def __init__(self, xyA, xyB, coordsA, coordsB=None,
+ axesA=None, axesB=None,
+ arrowstyle="-",
+ arrow_transmuter=None,
+ connectionstyle="arc3",
+ connector=None,
+ patchA=None,
+ patchB=None,
+ shrinkA=0.,
+ shrinkB=0.,
+ mutation_scale=10.,
+ mutation_aspect=None,
+ clip_on=False,
+ **kwargs):
+ """
+ Connect point *xyA* in *coordsA* with point *xyB* in *coordsB*
+
+
+ Valid keys are
+
+
+ =============== ======================================================
+ Key Description
+ =============== ======================================================
+ arrowstyle the arrow style
+ connectionstyle the connection style
+ relpos default is (0.5, 0.5)
+ patchA default is bounding box of the text
+ patchB default is None
+ shrinkA default is 2 points
+ shrinkB default is 2 points
+ mutation_scale default is text size (in points)
+ mutation_aspect default is 1.
+ ? any key for :class:`matplotlib.patches.PathPatch`
+ =============== ======================================================
+
+
+ *coordsA* and *coordsB* are strings that indicate the
+ coordinates of *xyA* and *xyB*.
+
+ ================= ===================================================
+ Property Description
+ ================= ===================================================
+ 'figure points' points from the lower left corner of the figure
+ 'figure pixels' pixels from the lower left corner of the figure
+ 'figure fraction' 0,0 is lower left of figure and 1,1 is upper, right
+ 'axes points' points from lower left corner of axes
+ 'axes pixels' pixels from lower left corner of axes
+ 'axes fraction' 0,1 is lower left of axes and 1,1 is upper right
+ 'data' use the coordinate system of the object being
+ annotated (default)
+ 'offset points' Specify an offset (in points) from the *xy* value
+
+ 'polar' you can specify *theta*, *r* for the annotation,
+ even in cartesian plots. Note that if you
+ are using a polar axes, you do not need
+ to specify polar for the coordinate
+ system since that is the native "data" coordinate
+ system.
+ ================= ===================================================
+
+ """
+ if coordsB is None:
+ coordsB = coordsA
+ # we'll draw ourself after the artist we annotate by default
+ self.xy1 = xyA
+ self.xy2 = xyB
+ self.coords1 = coordsA
+ self.coords2 = coordsB
+
+ self.axesA = axesA
+ self.axesB = axesB
+
+ FancyArrowPatch.__init__(self,
+ posA=(0,0), posB=(1,1),
+ arrowstyle=arrowstyle,
+ arrow_transmuter=arrow_transmuter,
+ connectionstyle=connectionstyle,
+ connector=connector,
+ patchA=patchA,
+ patchB=patchB,
+ shrinkA=shrinkA,
+ shrinkB=shrinkB,
+ mutation_scale=mutation_scale,
+ mutation_aspect=mutation_aspect,
+ clip_on=clip_on,
+ **kwargs)
+
+ # if True, draw annotation only if self.xy is inside the axes
+ self._annotation_clip = None
+
+ __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
+
+
+ def _get_xy(self, x, y, s, axes=None):
+ """
+ caculate the pixel position of given point
+ """
+
+ if axes is None:
+ axes = self.axes
+
+ if s=='data':
+ trans = axes.transData
+ x = float(self.convert_xunits(x))
+ y = float(self.convert_yunits(y))
+ return trans.transform_point((x, y))
+ elif s=='offset points':
+ # convert the data point
+ dx, dy = self.xy
+
+ # prevent recursion
+ if self.xycoords == 'offset points':
+ return self._get_xy(dx, dy, 'data')
+
+ dx, dy = self._get_xy(dx, dy, self.xycoords)
+
+ # convert the offset
+ dpi = self.figure.get_dpi()
+ x *= dpi/72.
+ y *= dpi/72.
+
+ # add the offset to the data point
+ x += dx
+ y += dy
+
+ return x, y
+ elif s=='polar':
+ theta, r = x, y
+ x = r*np.cos(theta)
+ y = r*np.sin(theta)
+ trans = axes.transData
+ return trans.transform_point((x,y))
+ elif s=='figure points':
+ #points from the lower left corner of the figure
+ dpi = self.figure.dpi
+ l,b,w,h = self.figure.bbox.bounds
+ r = l+w
+ t = b+h
+
+ x *= dpi/72.
+ y *= dpi/72.
+ if x<0:
+ x = r + x
+ if y<0:
+ y = t + y
+ return x,y
+ elif s=='figure pixels':
+ #pixels from the lower left corner of the figure
+ l,b,w,h = self.figure.bbox.bounds
+ r = l+w
+ t = b+h
+ if x<0:
+ x = r + x
+ if y<0:
+ y = t + y
+ return x, y
+ elif s=='figure fraction':
+ #(0,0) is lower left, (1,1) is upper right of figure
+ trans = self.figure.transFigure
+ return trans.transform_point((x,y))
+ elif s=='axes points':
+ #points from the lower left corner of the axes
+ dpi = self.figure.dpi
+ l,b,w,h = axes.bbox.bounds
+ r = l+w
+ t = b+h
+ if x<0:
+ x = r + x*dpi/72.
+ else:
+ x = l + x*dpi/72.
+ if y<0:
+ y = t + y*dpi/72.
+ else:
+ y = b + y*dpi/72.
+ return x, y
+ elif s=='axes pixels':
+ #pixels from the lower left corner of the axes
+
+ l,b,w,h = axes.bbox.bounds
+ r = l+w
+ t = b+h
+ if x<0:
+ x = r + x
+ else:
+ x = l + x
+ if y<0:
+ y = t + y
+ else:
+ y = b + y
+ return x, y
+ elif s=='axes fraction':
+ #(0,0) is lower left, (1,1) is upper right of axes
+ trans = axes.transAxes
+ return trans.transform_point((x, y))
+
+ def set_annotation_clip(self, b):
+ """
+ set *annotation_clip* attribute.
+
+ * True : the annotation will only be drawn when self.xy is inside the axes.
+ * False : the annotation will always be drawn regardless of its position.
+ * None : the self.xy will be checked only if *xycoords* is "data"
+ """
+ self._annotation_clip = b
+
+ def get_annotation_clip(self):
+ """
+ Return *annotation_clip* attribute.
+ See :meth:`set_annotation_clip` for the meaning of return values.
+ """
+ return self._annotation_clip
+
+
+ def get_path_in_displaycoord(self):
+ """
+ Return the mutated path of the arrow in the display coord
+ """
+
+ x, y = self.xy1
+ posA = self._get_xy(x, y, self.coords1, self.axesA)
+
+ x, y = self.xy2
+ posB = self._get_xy(x, y, self.coords1, self.axesB)
+
+ _path = self.get_connectionstyle()(posA, posB,
+ patchA=self.patchA,
+ patchB=self.patchB,
+ shrinkA=self.shrinkA,
+ shrinkB=self.shrinkB
+ )
+
+
+
+ _path, fillable = self.get_arrowstyle()(_path,
+ self.get_mutation_scale(),
+ self.get_linewidth(),
+ self.get_mutation_aspect()
+ )
+
+ return _path, fillable
+
+
+
+ def _check_xy(self, renderer):
+ """
+ check if the annotation need to
+ be drawn.
+ """
+
+ b = self.get_annotation_clip()
+
+
+ if b or (b is None and self.coords1 == "data"):
+ x, y = self.xy1
+ xy_pixel = self._get_xy(x, y, self.coords1, self.axesA)
+ if not self.axes.contains_point(xy_pixel):
+ return False
+
+ if b or (b is None and self.coords2 == "data"):
+ x, y = self.xy2
+ xy_pixel = self._get_xy(x, y, self.coords2, self.axesB)
+ if self.axesB is None:
+ axes = self.axes
+ else:
+ axes = self.axesB
+ if not axes.contains_point(xy_pixel):
+ return False
+
+ return True
+
+
+ def draw(self, renderer):
+ """
+ Draw.
+ """
+
+ if renderer is not None:
+ self._renderer = renderer
+ if not self.get_visible(): return
+
+ if not self._check_xy(renderer):
+ return
+
+ FancyArrowPatch.draw(self, renderer)
+
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-07-12 03:20:56
|
Revision: 7258
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7258&view=rev
Author: jdh2358
Date: 2009-07-12 03:20:53 +0000 (Sun, 12 Jul 2009)
Log Message:
-----------
use png icon on gtk for win32
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
trunk/matplotlib/lib/matplotlib/lines.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2009-07-11 20:18:06 UTC (rev 7257)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2009-07-12 03:20:53 UTC (rev 7258)
@@ -1148,7 +1148,7 @@
# versions of pygtk, so we have to use a PNG file instead.
try:
- if gtk.pygtk_version < (2, 8, 0):
+ if gtk.pygtk_version < (2, 8, 0) or sys.platform == 'win32':
icon_filename = 'matplotlib.png'
else:
icon_filename = 'matplotlib.svg'
Modified: trunk/matplotlib/lib/matplotlib/lines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/lines.py 2009-07-11 20:18:06 UTC (rev 7257)
+++ trunk/matplotlib/lib/matplotlib/lines.py 2009-07-12 03:20:53 UTC (rev 7258)
@@ -335,10 +335,10 @@
def set_fillstyle(self, fs):
"""
- Set the marker fill style; full means fill the whole marker.
- The other options are for half fills
+ Set the marker fill style; 'full' means fill the whole marker.
+ The other options are for half filled markers
- ACCEPTS: string ['full' | 'left' | 'right' | 'bottom' | 'top']
+ ACCEPTS: ['full' | 'left' | 'right' | 'bottom' | 'top']
"""
assert fs in ['full', 'left' , 'right' , 'bottom' , 'top']
self._fillstyle = fs
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-07-11 20:18:11
|
Revision: 7257
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7257&view=rev
Author: jdh2358
Date: 2009-07-11 20:18:06 +0000 (Sat, 11 Jul 2009)
Log Message:
-----------
centered ticklabel examples
Added Paths:
-----------
trunk/matplotlib/examples/pylab_examples/centered_ticklabels.py
Added: trunk/matplotlib/examples/pylab_examples/centered_ticklabels.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/centered_ticklabels.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/centered_ticklabels.py 2009-07-11 20:18:06 UTC (rev 7257)
@@ -0,0 +1,44 @@
+# sometimes it is nice to have ticklabels centered. mpl currently
+# associates a label with a tick, and the label can be aligned
+# 'center', 'feft', or 'right' using the horizontal alignment property:
+#
+#
+# for label in ax.xaxis.get_xticklabels():
+# label.set_horizntal_alignment('right')
+#
+#
+# but this doesn't help center the label between ticks. One solution
+# is to "face it". Use the minor ticks to place a tick centered
+# between the major ticks. Here is an example that labels the months,
+# centered between the ticks
+
+import datetime
+import numpy as np
+import matplotlib
+import matplotlib.dates as dates
+import matplotlib.ticker as ticker
+import matplotlib.pyplot as plt
+
+# load some financial data; apple's stock price
+fh = matplotlib.get_example_data('aapl.npy')
+r = np.load(fh); fh.close()
+r = r[-250:] # get the last 250 days
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.plot(r.date, r.adj_close)
+
+ax.xaxis.set_major_locator(dates.MonthLocator())
+ax.xaxis.set_minor_locator(dates.MonthLocator(bymonthday=15))
+
+ax.xaxis.set_major_formatter(ticker.NullFormatter())
+ax.xaxis.set_minor_formatter(dates.DateFormatter('%b'))
+
+for tick in ax.xaxis.get_minor_ticks():
+ tick.tick1line.set_markersize(0)
+ tick.tick2line.set_markersize(0)
+ tick.label1.set_horizontalalignment('center')
+
+imid = len(r)/2
+ax.set_xlabel(str(r.date[imid].year))
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2009-07-11 18:06:59
|
Revision: 7256
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7256&view=rev
Author: efiring
Date: 2009-07-11 18:06:54 +0000 (Sat, 11 Jul 2009)
Log Message:
-----------
Yet another iteration on the version checking in backend_wx
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2009-07-11 16:52:44 UTC (rev 7255)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2009-07-11 18:06:54 UTC (rev 7256)
@@ -116,28 +116,31 @@
raise ImportError(missingwx)
# Some early versions of wxversion lack AlreadyImportedError.
-if hasattr(wxversion, 'AlreadyImportedError'):
- try:
- wxversion.ensureMinimal('2.8')
- except wxversion.AlreadyImportedError:
- pass
-else:
- warnings.warn(
- "Update your wxversion.py to one including AlreadyImportedError")
- try:
- wxversion.ensureMinimal('2.8')
- except wxversion.VersionError:
- pass
+# It was added around 2.8.4?
+try:
+ _wx_ensure_failed = wxversion.AlreadyImportedError
+except AttributeError:
+ _wx_ensure_failed = wxversion.VersionError
try:
+ wxversion.ensureMinimal('2.8')
+except _wx_ensure_failed:
+ pass
+# We don't really want to pass in case of VersionError, but when
+# AlreadyImportedError is not available, we have to.
+
+try:
import wx
backend_version = wx.VERSION_STRING
except ImportError:
raise ImportError(missingwx)
-# Extra version check in case wxversion is broken:
+# Extra version check in case wxversion lacks AlreadyImportedError;
+# then VersionError might have been raised and ignored when
+# there really *is* a problem with the version.
major, minor = [int(n) for n in backend_version.split('.')[:2]]
if major < 2 or (major < 3 and minor < 8):
+ print " wxPython version %s was imported." % backend_version
raise ImportError(missingwx)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-07-11 16:52:47
|
Revision: 7255
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7255&view=rev
Author: jdh2358
Date: 2009-07-11 16:52:44 +0000 (Sat, 11 Jul 2009)
Log Message:
-----------
added fillstyle property to Line2D
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/lines.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-07-11 12:42:46 UTC (rev 7254)
+++ trunk/matplotlib/CHANGELOG 2009-07-11 16:52:44 UTC (rev 7255)
@@ -1,3 +1,6 @@
+2009-07-11 Added a fillstyle Line2D property for half filled markers
+ -- see examples/pylab_examples/fillstyle_demo.py JDH
+
2009-07-08 Attempt to improve performance of qt4 backend, do not call
qApp.processEvents while processing an event. Thanks Ole
Streicher for tracking this down - DSD
Modified: trunk/matplotlib/lib/matplotlib/lines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/lines.py 2009-07-11 12:42:46 UTC (rev 7254)
+++ trunk/matplotlib/lib/matplotlib/lines.py 2009-07-11 16:52:44 UTC (rev 7255)
@@ -172,6 +172,7 @@
markeredgewidth = None,
markeredgecolor = None,
markerfacecolor = None,
+ fillstyle = 'full',
antialiased = None,
dash_capstyle = None,
solid_capstyle = None,
@@ -238,6 +239,8 @@
self.set_markerfacecolor(markerfacecolor)
self.set_markeredgecolor(markeredgecolor)
self.set_markeredgewidth(markeredgewidth)
+ self.set_fillstyle(fillstyle)
+
self._point_size_reduction = 0.5
self.verticalOffset = None
@@ -324,7 +327,22 @@
"""
self.pickradius = d
+ def get_fillstyle(self):
+ """
+ return the marker fillstyle
+ """
+ return self._fillstyle
+ def set_fillstyle(self, fs):
+ """
+ Set the marker fill style; full means fill the whole marker.
+ The other options are for half fills
+
+ ACCEPTS: string ['full' | 'left' | 'right' | 'bottom' | 'top']
+ """
+ assert fs in ['full', 'left' , 'right' , 'bottom' , 'top']
+ self._fillstyle = fs
+
def set_markevery(self, every):
"""
Set the markevery property to subsample the plot when using
@@ -918,6 +936,10 @@
def _draw_point(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been implemented for this marker style yet; please contribute')
+
w = renderer.points_to_pixels(self._markersize) * \
self._point_size_reduction * 0.5
gc.set_snap(renderer.points_to_pixels(self._markersize) > 3.0)
@@ -929,6 +951,10 @@
_draw_pixel_transform = Affine2D().translate(-0.5, -0.5)
def _draw_pixel(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been implemented for this marker style yet; please contribute')
+
rgbFace = self._get_rgb_face()
gc.set_snap(False)
renderer.draw_markers(gc, Path.unit_rectangle(),
@@ -937,6 +963,10 @@
def _draw_circle(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been implemented for this marker style yet; please contribute')
+
w = renderer.points_to_pixels(self._markersize) * 0.5
gc.set_snap(renderer.points_to_pixels(self._markersize) > 3.0)
rgbFace = self._get_rgb_face()
@@ -948,6 +978,11 @@
_triangle_path = Path([[0.0, 1.0], [-1.0, -1.0], [1.0, -1.0], [0.0, 1.0]])
def _draw_triangle_up(self, renderer, gc, path, path_trans):
+
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been implemented for this marker style yet; please contribute')
+
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5*renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset, offset)
@@ -957,6 +992,10 @@
def _draw_triangle_down(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been implemented for this marker style yet; please contribute')
+
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5*renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset, -offset)
@@ -966,6 +1005,10 @@
def _draw_triangle_left(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been implemented for this marker style yet; please contribute')
+
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5*renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset, offset).rotate_deg(90)
@@ -975,6 +1018,10 @@
def _draw_triangle_right(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been implemented for this marker style yet; please contribute')
+
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5*renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset, offset).rotate_deg(-90)
@@ -988,11 +1035,31 @@
side = renderer.points_to_pixels(self._markersize)
transform = Affine2D().translate(-0.5, -0.5).scale(side)
rgbFace = self._get_rgb_face()
- renderer.draw_markers(gc, Path.unit_rectangle(), transform,
- path, path_trans, rgbFace)
+ fs = self.get_fillstyle()
+ if fs=='full':
+ renderer.draw_markers(gc, Path.unit_rectangle(), transform,
+ path, path_trans, rgbFace)
+ else:
+ # build a bottom filled square out of two rectangles, one
+ # filled. Use the rotation to support left, right, bottom
+ # or top
+ if fs=='bottom': rotate = 0.
+ elif fs=='top': rotate = 180.
+ elif fs=='left': rotate = 270.
+ else: rotate = 90.
+ bottom = Path([[0.0, 0.0], [1.0, 0.0], [1.0, 0.5], [0.0, 0.5], [0.0, 0.0]])
+ top = Path([[0.0, 0.5], [1.0, 0.5], [1.0, 1.0], [0.0, 1.0], [0.0, 0.05]])
+ transform = transform.rotate_deg(rotate)
+ renderer.draw_markers(gc, bottom, transform,
+ path, path_trans, rgbFace)
+ renderer.draw_markers(gc, top, transform,
+ path, path_trans, None)
def _draw_diamond(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been implemented for this marker style yet; please contribute')
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
side = renderer.points_to_pixels(self._markersize)
transform = Affine2D().translate(-0.5, -0.5).rotate_deg(45).scale(side)
@@ -1002,6 +1069,9 @@
def _draw_thin_diamond(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been implemented for this marker style yet; please contribute')
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 3.0)
offset = renderer.points_to_pixels(self._markersize)
transform = Affine2D().translate(-0.5, -0.5) \
@@ -1012,6 +1082,9 @@
def _draw_pentagon(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been implemented for this marker style yet; please contribute')
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5 * renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset)
@@ -1020,6 +1093,9 @@
path, path_trans, rgbFace)
def _draw_star(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been implemented for this marker style yet; please contribute')
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5 * renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset)
@@ -1030,6 +1106,9 @@
def _draw_hexagon1(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been implemented for this marker style yet; please contribute')
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5 * renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset)
@@ -1039,6 +1118,9 @@
def _draw_hexagon2(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been implemented for this marker style yet; please contribute')
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5 * renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset).rotate_deg(30)
@@ -1203,6 +1285,7 @@
self._markerfacecolor = other._markerfacecolor
self._markeredgecolor = other._markeredgecolor
self._markeredgewidth = other._markeredgewidth
+ self._fillstyle = other._fillstyle
self._dashSeq = other._dashSeq
self._dashcapstyle = other._dashcapstyle
self._dashjoinstyle = other._dashjoinstyle
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-07-11 12:42:51
|
Revision: 7254
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7254&view=rev
Author: jdh2358
Date: 2009-07-11 12:42:46 +0000 (Sat, 11 Jul 2009)
Log Message:
-----------
Merged revisions 7253 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint
........
r7253 | jdh2358 | 2009-07-11 07:39:29 -0500 (Sat, 11 Jul 2009) | 1 line
applied osx setpext patch from sf #2818964
........
Modified Paths:
--------------
trunk/matplotlib/setupext.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7245
+ /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253
Modified: trunk/matplotlib/setupext.py
===================================================================
--- trunk/matplotlib/setupext.py 2009-07-11 12:39:29 UTC (rev 7253)
+++ trunk/matplotlib/setupext.py 2009-07-11 12:42:46 UTC (rev 7254)
@@ -138,6 +138,9 @@
try: options['build_wxagg'] = config.getboolean("gui_support", "wxagg")
except: options['build_wxagg'] = 'auto'
+ try: options['build_macosx'] = config.getboolean("gui_support", "macosx")
+ except: options['build_macosx'] = 'auto'
+
try: options['backend'] = config.get("rc_options", "backend")
except: pass
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-07-11 12:39:35
|
Revision: 7253
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7253&view=rev
Author: jdh2358
Date: 2009-07-11 12:39:29 +0000 (Sat, 11 Jul 2009)
Log Message:
-----------
applied osx setpext patch from sf #2818964
Modified Paths:
--------------
branches/v0_98_5_maint/setupext.py
Modified: branches/v0_98_5_maint/setupext.py
===================================================================
--- branches/v0_98_5_maint/setupext.py 2009-07-10 21:32:27 UTC (rev 7252)
+++ branches/v0_98_5_maint/setupext.py 2009-07-11 12:39:29 UTC (rev 7253)
@@ -140,6 +140,9 @@
try: options['build_wxagg'] = config.getboolean("gui_support", "wxagg")
except: options['build_wxagg'] = 'auto'
+ try: options['build_macosx'] = config.getboolean("gui_support", "macosx")
+ except: options['build_macosx'] = 'auto'
+
try: options['backend'] = config.get("rc_options", "backend")
except: pass
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2009-07-10 21:32:39
|
Revision: 7252
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7252&view=rev
Author: efiring
Date: 2009-07-10 21:32:27 +0000 (Fri, 10 Jul 2009)
Log Message:
-----------
Another fix for wxversion problem (thanks, Gael Varoquaux)
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2009-07-10 19:41:12 UTC (rev 7251)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2009-07-10 21:32:27 UTC (rev 7252)
@@ -124,6 +124,10 @@
else:
warnings.warn(
"Update your wxversion.py to one including AlreadyImportedError")
+ try:
+ wxversion.ensureMinimal('2.8')
+ except wxversion.VersionError:
+ pass
try:
import wx
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2009-07-10 19:41:21
|
Revision: 7251
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7251&view=rev
Author: efiring
Date: 2009-07-10 19:41:12 +0000 (Fri, 10 Jul 2009)
Log Message:
-----------
Allow for broken wxversion in backend_wx
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2009-07-08 21:15:46 UTC (rev 7250)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2009-07-10 19:41:12 UTC (rev 7251)
@@ -115,10 +115,15 @@
except ImportError:
raise ImportError(missingwx)
-try:
- wxversion.ensureMinimal('2.8')
-except wxversion.AlreadyImportedError:
- pass
+# Some early versions of wxversion lack AlreadyImportedError.
+if hasattr(wxversion, 'AlreadyImportedError'):
+ try:
+ wxversion.ensureMinimal('2.8')
+ except wxversion.AlreadyImportedError:
+ pass
+else:
+ warnings.warn(
+ "Update your wxversion.py to one including AlreadyImportedError")
try:
import wx
@@ -126,6 +131,12 @@
except ImportError:
raise ImportError(missingwx)
+# Extra version check in case wxversion is broken:
+major, minor = [int(n) for n in backend_version.split('.')[:2]]
+if major < 2 or (major < 3 and minor < 8):
+ raise ImportError(missingwx)
+
+
#!!! this is the call that is causing the exception swallowing !!!
#wx.InitAllImageHandlers()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2009-07-08 21:15:54
|
Revision: 7250
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7250&view=rev
Author: dsdale
Date: 2009-07-08 21:15:46 +0000 (Wed, 08 Jul 2009)
Log Message:
-----------
improve resizing behavior of qt4 backend
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-07-07 12:41:45 UTC (rev 7249)
+++ trunk/matplotlib/CHANGELOG 2009-07-08 21:15:46 UTC (rev 7250)
@@ -1,3 +1,7 @@
+2009-07-08 Attempt to improve performance of qt4 backend, do not call
+ qApp.processEvents while processing an event. Thanks Ole
+ Streicher for tracking this down - DSD
+
2009-06-24 Add withheader option to mlab.rec2csv and changed
use_mrecords default to False in mlab.csv2rec since this is
partially broken - JDH
@@ -2,3 +6,2 @@
-
2009-06-24 backend_agg.draw_marker quantizes the main path (as in the
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2009-07-07 12:41:45 UTC (rev 7249)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2009-07-08 21:15:46 UTC (rev 7250)
@@ -158,7 +158,6 @@
def resizeEvent( self, event ):
if DEBUG: print 'resize (%d x %d)' % (event.size().width(), event.size().height())
- QtGui.QWidget.resizeEvent( self, event )
w = event.size().width()
h = event.size().height()
if DEBUG: print "FigureCanvasQtAgg.resizeEvent(", w, ",", h, ")"
@@ -167,20 +166,9 @@
hinch = h/dpival
self.figure.set_size_inches( winch, hinch )
self.draw()
+ self.update()
+ QtGui.QWidget.resizeEvent(self, event)
- def resize( self, w, h ):
- # Pass through to Qt to resize the widget.
- QtGui.QWidget.resize( self, w, h )
-
- # Resize the figure by converting pixels to inches.
- pixelPerInch = self.figure.dpi
- wInch = w / pixelPerInch
- hInch = h / pixelPerInch
- self.figure.set_size_inches( wInch, hInch )
-
- # Redraw everything.
- self.draw()
-
def sizeHint( self ):
w, h = self.get_width_height()
return QtCore.QSize( w, h )
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2009-07-07 12:41:45 UTC (rev 7249)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2009-07-08 21:15:46 UTC (rev 7250)
@@ -61,9 +61,6 @@
self.replot = True
self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)
- def resizeEvent( self, e ):
- FigureCanvasQT.resizeEvent( self, e )
-
def drawRectangle( self, rect ):
self.rect = rect
self.drawRect = True
@@ -132,8 +129,6 @@
self.replot = True
FigureCanvasAgg.draw(self)
self.update()
- # Added following line to improve realtime pan/zoom on windows:
- QtGui.qApp.processEvents()
def blit(self, bbox=None):
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-07-07 12:41:49
|
Revision: 7249
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7249&view=rev
Author: mdboom
Date: 2009-07-07 12:41:45 +0000 (Tue, 07 Jul 2009)
Log Message:
-----------
[2687673] Add abs() to delta check in Mollweide projection.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/projections/geo.py
Modified: trunk/matplotlib/lib/matplotlib/projections/geo.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/projections/geo.py 2009-07-06 19:43:00 UTC (rev 7248)
+++ trunk/matplotlib/lib/matplotlib/projections/geo.py 2009-07-07 12:41:45 UTC (rev 7249)
@@ -424,7 +424,7 @@
def transform(self, ll):
def d(theta):
delta = -(theta + np.sin(theta) - pi_sin_l) / (1 + np.cos(theta))
- return delta, delta > 0.001
+ return delta, abs(delta) > 0.001
longitude = ll[:, 0:1]
latitude = ll[:, 1:2]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-07-06 19:43:06
|
Revision: 7248
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7248&view=rev
Author: mdboom
Date: 2009-07-06 19:43:00 +0000 (Mon, 06 Jul 2009)
Log Message:
-----------
[2687673] Fix problems with Mollweide projection, enable it, and add to geo_demo.py
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/geo_demo.py
trunk/matplotlib/lib/matplotlib/projections/__init__.py
trunk/matplotlib/lib/matplotlib/projections/geo.py
Modified: trunk/matplotlib/examples/pylab_examples/geo_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/geo_demo.py 2009-07-03 19:35:35 UTC (rev 7247)
+++ trunk/matplotlib/examples/pylab_examples/geo_demo.py 2009-07-06 19:43:00 UTC (rev 7248)
@@ -4,13 +4,19 @@
from pylab import *
subplot(221, projection="aitoff")
+title("Aitoff")
grid(True)
subplot(222, projection="hammer")
+title("Hammer")
grid(True)
subplot(223, projection="lambert")
+title("Lambert")
grid(True)
+subplot(224, projection="mollweide")
+title("Mollweide")
+grid(True)
show()
Modified: trunk/matplotlib/lib/matplotlib/projections/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/projections/__init__.py 2009-07-03 19:35:35 UTC (rev 7247)
+++ trunk/matplotlib/lib/matplotlib/projections/__init__.py 2009-07-06 19:43:00 UTC (rev 7248)
@@ -1,4 +1,4 @@
-from geo import AitoffAxes, HammerAxes, LambertAxes
+from geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes
from polar import PolarAxes
from matplotlib import axes
@@ -38,7 +38,8 @@
PolarAxes,
AitoffAxes,
HammerAxes,
- LambertAxes)
+ LambertAxes,
+ MollweideAxes)
def register_projection(cls):
Modified: trunk/matplotlib/lib/matplotlib/projections/geo.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/projections/geo.py 2009-07-03 19:35:35 UTC (rev 7247)
+++ trunk/matplotlib/lib/matplotlib/projections/geo.py 2009-07-06 19:43:00 UTC (rev 7248)
@@ -422,10 +422,21 @@
self._resolution = resolution
def transform(self, ll):
+ def d(theta):
+ delta = -(theta + np.sin(theta) - pi_sin_l) / (1 + np.cos(theta))
+ return delta, delta > 0.001
+
longitude = ll[:, 0:1]
latitude = ll[:, 1:2]
- aux = 2.0 * np.arcsin((2.0 * latitude) / np.pi)
+ pi_sin_l = np.pi * np.sin(latitude)
+ theta = 2.0 * latitude
+ delta, large_delta = d(theta)
+ while np.any(large_delta):
+ theta += np.where(large_delta, delta, 0)
+ delta, large_delta = d(theta)
+ aux = theta / 2
+
x = (2.0 * np.sqrt(2.0) * longitude * np.cos(aux)) / np.pi
y = (np.sqrt(2.0) * np.sin(aux))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-07-03 19:35:43
|
Revision: 7247
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7247&view=rev
Author: leejjoon
Date: 2009-07-03 19:35:35 +0000 (Fri, 03 Jul 2009)
Log Message:
-----------
axes_grid: respect angle and alignment of ticklabels
Modified Paths:
--------------
trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py 2009-07-01 20:01:00 UTC (rev 7246)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/axislines.py 2009-07-03 19:35:35 UTC (rev 7247)
@@ -995,19 +995,21 @@
trans, vert, horiz, label_a = tvhl
trans = transform + trans
+ # ignore ticklabel angle during the drawing time (but respect
+ # during init). Instead, use angle set by the TickLabel
+ # artist.
+
self.major_ticklabels = TickLabels(size, axis=self.axis)
self.minor_ticklabels = TickLabels(size, axis=self.axis)
self.major_ticklabels.set(figure = self.axes.figure,
- rotation = label_a,
transform=trans,
va=vert,
ha=horiz,
fontproperties=fontprops)
self.minor_ticklabels.set(figure = self.axes.figure,
- rotation = label_a,
transform=trans,
va=vert,
ha=horiz,
@@ -1067,10 +1069,11 @@
trans, va, ha, a = tvhl
trans = transform + trans
- self.major_ticklabels.set(transform=trans,
- va=va, ha=ha, rotation=a)
+ # ignore va, ha, angle during the drawing time
+ self.major_ticklabels.set_transform(trans)
+
self.major_ticks.update_ticks(tick_loc_angle_label, renderer)
self.major_ticklabels.update_ticks(tick_loc_angle_label, renderer)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-07-01 20:01:03
|
Revision: 7246
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7246&view=rev
Author: mdboom
Date: 2009-07-01 20:01:00 +0000 (Wed, 01 Jul 2009)
Log Message:
-----------
Merged revisions 7245 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_98_5_maint
........
r7245 | mdboom | 2009-07-01 15:55:17 -0400 (Wed, 01 Jul 2009) | 1 line
Fix out-of-memory errors leading to segfaults
........
Modified Paths:
--------------
trunk/matplotlib/src/_path.cpp
trunk/matplotlib/src/_png.cpp
Property Changed:
----------------
trunk/matplotlib/
trunk/matplotlib/doc/pyplots/README
trunk/matplotlib/doc/sphinxext/gen_gallery.py
trunk/matplotlib/doc/sphinxext/gen_rst.py
trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py
trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py
trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7229
+ /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7245
Modified: svn:mergeinfo
- /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227
+ /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
Property changes on: trunk/matplotlib/doc/pyplots/README
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227
+ /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227
+ /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227
+ /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/sphinxext/mathmpl.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/mathmpl.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227
+ /branches/v0_91_maint/doc/sphinxext/mathmpl.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/mathmpl.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/sphinxext/only_directives.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/only_directives.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227
+ /branches/v0_91_maint/doc/sphinxext/only_directives.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/only_directives.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/sphinxext/plot_directive.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py:6920-6925,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227
+ /branches/v0_91_maint/doc/sphinxext/plot_directive.py:5753-5771
/branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py:6920-6925,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2009-07-01 19:55:17 UTC (rev 7245)
+++ trunk/matplotlib/src/_path.cpp 2009-07-01 20:01:00 UTC (rev 7246)
@@ -886,6 +886,9 @@
size_t size = p->size();
dims[0] = p->size();
PyArrayObject* pyarray = (PyArrayObject*)PyArray_SimpleNew(2, dims, PyArray_DOUBLE);
+ if (pyarray == NULL) {
+ throw Py::MemoryError("Could not allocate result array");
+ }
for (size_t i = 0; i < size; ++i)
{
((double *)pyarray->data)[2*i] = (*p)[i].x;
@@ -955,6 +958,9 @@
result = (PyArrayObject*)PyArray_SimpleNew
(PyArray_NDIM(vertices), PyArray_DIMS(vertices), PyArray_DOUBLE);
+ if (result == NULL) {
+ throw Py::MemoryError("Could not allocate memory for path");
+ }
if (PyArray_NDIM(vertices) == 2)
{
size_t n = PyArray_DIM(vertices, 0);
Modified: trunk/matplotlib/src/_png.cpp
===================================================================
--- trunk/matplotlib/src/_png.cpp 2009-07-01 19:55:17 UTC (rev 7245)
+++ trunk/matplotlib/src/_png.cpp 2009-07-01 20:01:00 UTC (rev 7246)
@@ -266,6 +266,10 @@
double max_value = (1 << ((bit_depth < 8) ? 8 : bit_depth)) - 1;
PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(num_dims, dimensions, PyArray_FLOAT);
+ if (A == NULL) {
+ throw Py::MemoryError("Could not allocate image array");
+ }
+
for (png_uint_32 y = 0; y < height; y++) {
png_byte* row = row_pointers[y];
for (png_uint_32 x = 0; x < width; x++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-07-01 19:55:19
|
Revision: 7245
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7245&view=rev
Author: mdboom
Date: 2009-07-01 19:55:17 +0000 (Wed, 01 Jul 2009)
Log Message:
-----------
Fix out-of-memory errors leading to segfaults
Modified Paths:
--------------
branches/v0_98_5_maint/src/_path.cpp
branches/v0_98_5_maint/src/_png.cpp
Modified: branches/v0_98_5_maint/src/_path.cpp
===================================================================
--- branches/v0_98_5_maint/src/_path.cpp 2009-06-29 15:11:00 UTC (rev 7244)
+++ branches/v0_98_5_maint/src/_path.cpp 2009-07-01 19:55:17 UTC (rev 7245)
@@ -882,6 +882,9 @@
size_t size = p->size();
dims[0] = p->size();
PyArrayObject* pyarray = (PyArrayObject*)PyArray_SimpleNew(2, dims, PyArray_DOUBLE);
+ if (pyarray == NULL) {
+ throw Py::MemoryError("Could not allocate result array");
+ }
for (size_t i = 0; i < size; ++i)
{
((double *)pyarray->data)[2*i] = (*p)[i].x;
@@ -951,6 +954,9 @@
result = (PyArrayObject*)PyArray_SimpleNew
(PyArray_NDIM(vertices), PyArray_DIMS(vertices), PyArray_DOUBLE);
+ if (result == NULL) {
+ throw Py::MemoryError("Could not allocate memory for path");
+ }
if (PyArray_NDIM(vertices) == 2)
{
size_t n = PyArray_DIM(vertices, 0);
Modified: branches/v0_98_5_maint/src/_png.cpp
===================================================================
--- branches/v0_98_5_maint/src/_png.cpp 2009-06-29 15:11:00 UTC (rev 7244)
+++ branches/v0_98_5_maint/src/_png.cpp 2009-07-01 19:55:17 UTC (rev 7245)
@@ -266,6 +266,10 @@
double max_value = (1 << ((bit_depth < 8) ? 8 : bit_depth)) - 1;
PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(num_dims, dimensions, PyArray_FLOAT);
+ if (A == NULL) {
+ throw Py::MemoryError("Could not allocate image array");
+ }
+
for (png_uint_32 y = 0; y < height; y++) {
png_byte* row = row_pointers[y];
for (png_uint_32 x = 0; x < width; x++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-06-29 15:11:04
|
Revision: 7244
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7244&view=rev
Author: leejjoon
Date: 2009-06-29 15:11:00 +0000 (Mon, 29 Jun 2009)
Log Message:
-----------
axes_grid: doc update
Modified Paths:
--------------
trunk/matplotlib/examples/axes_grid/demo_floating_axis.py
trunk/matplotlib/lib/mpl_toolkits/axes_grid/grid_helper_curvelinear.py
Added Paths:
-----------
trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axislines.rst
Added: trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axislines.rst
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axislines.rst (rev 0)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/axislines.rst 2009-06-29 15:11:00 UTC (rev 7244)
@@ -0,0 +1,250 @@
+.. _axislines-manual:
+
+=========
+Axislines
+=========
+
+Axislines includes a derived Axes implementation. The
+biggest difference is that the artists responsible to draw axis line,
+ticks, ticklabel and axis labels are separated out from the mpl's Axis
+class, which are much more than artists in the original
+mpl. This change was strongly motivated to support curvlinear
+grid. Here are a few things that axes_grid.axislines.Axes is different
+from original Axes from mpl.
+
+* Axis elements (axis line(spine), ticks, ticklabel and axis labels)
+ are drawn by a AxisArtist instance. Unlike Axis, left, right, top
+ and bottom axis are drawn by separate artists. And each of them may
+ have different tick location and different tick labels.
+
+* gridlines are drawn by a Gridlines instance. The change was
+ motivated that in curvelinear coordinate, a gridline may not cross
+ axislines (i.e., no associated ticks). In the original Axes class,
+ gridlines are tied to ticks.
+
+* ticklines can be rotated if necessary (i.e, along the gridlines)
+
+In summary, all these changes was to support
+
+* a curvelinear grid.
+* a floating axis
+
+.. plot:: mpl_toolkits/axes_grid/figures/demo_floating_axis.py
+
+
+*axes_grid.axislines.Axes* defines a *axis* attribute, which is a
+dictionary of AxisArtist instances. By default, the dictionary has 4
+AxisArtist instances, responsible for drawing of left, right, bottom
+and top axis.
+
+xaxis and yaxis attributes are still available, however they are set
+to not visible. As separate artists are used for rendering axis, some
+axis-related method in mpl may have no effect.
+In addition to AxisArtist instances, the axes_grid.axislines.Axes will
+have *gridlines* attribute (Gridlines), which obviously draws grid
+lines.
+
+In both AxisArtist and Gridlines, the calculation of tick and grid
+location is delegated to an instance of GridHelper class.
+axes_grid.axislines.Axes class uses GridHelperRectlinear as a grid
+helper. The GridHelperRectlinear class is a wrapper around the *xaxis*
+and *yaxis* of mpl's original Axes, and it was meant to work as the
+way how mpl's original axes works. For example, tick location changes
+using set_ticks method and etc. should work as expected. But change in
+artist properties (e.g., color) will not work in general, although
+some effort has been made so that some often-change attributes (color,
+etc.) are respected.
+
+
+AxisArtist
+==========
+
+AxisArtist can be considered as a container artist with following
+attributes which will draw ticks, labels, etc.
+
+ * line
+ * major_ticks, major_ticklabels
+ * minor_ticks, minor_ticklabels
+ * offsetText
+ * label
+
+
+line
+----
+
+Derived from Line2d class. Responsible for drawing a spinal(?) line.
+
+major_ticks, minor_ticks
+------------------------
+
+Derived from Line2d class. Note that ticks are markers.
+
+
+major_ticklabels, minor_ticklabels
+----------------------------------
+
+Derived from Text. Note that it is not a list of Text artist, but a
+single artist (similar to a collection).
+
+axislabel
+---------
+
+Derived from Text.
+
+
+Default AxisArtists
+-------------------
+
+By default, following for axis artists are defined.::
+
+ ax.axis["left"], ax.axis["bottom"], ax.axis["right"], ax.axis["top"]
+
+The ticklabels and axislabel of the top and the right axis are set to
+not visible.
+
+
+HowTo
+=====
+
+1. Changing tick locations and label.
+
+ Same as the original mpl's axes.::
+
+ ax.set_xticks([1,2,3])
+
+2. Changing axis properties like color, etc.
+
+ Change the properties of appropriate artists. For example, to change
+ the color of the ticklabels::
+
+ ax.axis["left"].major_ticklabels.set_color("r")
+
+
+GridHelper
+==========
+
+To actually define a curvelinear coordinate, you have to use your own
+grid helper. A generalised version of grid helper class is supplied
+and this class should be suffice in most of cases. A user may provide
+two functions which defines a transformation (and its inverse pair)
+from the curved coordinate to (rectlinear) image coordinate. Note that
+while ticks and grids are drawn for curved coordinate, the data
+transform of the axes itself (ax.transData) is still rectlinear
+(image) coordinate. ::
+
+
+ from mpl_toolkits.axes_grid.grid_helper_curvelinear \
+ import GridHelperCurveLinear
+ from mpl_toolkits.axes_grid.axislines import Subplot
+
+ # from curved coordinate to rectlinear coordinate.
+ def tr(x, y):
+ x, y = np.asarray(x), np.asarray(y)
+ return x, y-x
+
+ # from rectlinear coordinate to curved coordinate.
+ def inv_tr(x,y):
+ x, y = np.asarray(x), np.asarray(y)
+ return x, y+x
+
+
+ grid_helper = GridHelperCurveLinear((tr, inv_tr))
+
+ ax1 = Subplot(fig, 1, 1, 1, grid_helper=grid_helper)
+
+ fig.add_subplot(ax1)
+
+
+You may use matplotlib's Transform instance instead (but a
+inverse transformation must be defined). Often, coordinate range in a
+curved coordinate system may have a limited range, or may have
+cycles. In those cases, a more customized version of grid helper is
+required. ::
+
+
+ import mpl_toolkits.axes_grid.angle_helper as angle_helper
+
+ # PolarAxes.PolarTransform takes radian. However, we want our coordinate
+ # system in degree
+ tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform()
+
+
+ # extreme finder : find a range of coordinate.
+ # 20, 20 : number of sampling points along x, y direction
+ # The first coordinate (longitude, but theta in polar)
+ # has a cycle of 360 degree.
+ # The second coordinate (latitude, but radius in polar) has a minimum of 0
+ extreme_finder = angle_helper.ExtremeFinderCycle(20, 20,
+ lon_cycle = 360,
+ lat_cycle = None,
+ lon_minmax = None,
+ lat_minmax = (0, np.inf),
+ )
+
+ # Find a grid values appropriate for the coordinate (degree,
+ # minute, second). The argument is a approximate number of grids.
+ grid_locator1 = angle_helper.LocatorDMS(12)
+
+ # And also uses an appropriate formatter. Note that,the
+ # acceptable Locator and Formatter class is a bit different than
+ # that of mpl's, and you cannot directly use mpl's Locator and
+ # Formatter here (but may be possible in the future).
+ tick_formatter1 = angle_helper.FormatterDMS()
+
+ grid_helper = GridHelperCurveLinear(tr,
+ extreme_finder=extreme_finder,
+ grid_locator1=grid_locator1,
+ tick_formatter1=tick_formatter1
+ )
+
+
+Again, the *transData* of the axes is still a rectlinear coordinate
+(image coordinate). You may manually do conversion between two
+coordinates, or you may use Parasite Axes for convenience.::
+
+ ax1 = SubplotHost(fig, 1, 2, 2, grid_helper=grid_helper)
+
+ # A parasite axes with given transform
+ ax2 = ParasiteAxesAuxTrans(ax1, tr, "equal")
+ # note that ax2.transData == tr + ax1.transData
+ # Anthing you draw in ax2 will match the ticks and grids of ax1.
+ ax1.parasites.append(ax2)
+
+
+.. plot:: mpl_toolkits/axes_grid/figures/demo_curvelinear_grid.py
+
+
+
+FloatingAxis
+============
+
+A floating axis is an axis one of whose data coordinate is fixed, i.e,
+its location is not fixed in Axes coordinate but changes as axes data
+limits changes. A floating axis can be created using
+*new_floating_axis* method. However, it is your responsibility that
+the resulting AxisArtist is properly added to the axes. A recommended
+way is to add it as an item of Axes's axis attribute.::
+
+ # floating axis whose first (index starts from 0) coordinate
+ # (theta) is fixed at 60
+
+ ax1.axis["lat"] = axis = ax1.new_floating_axis(0, 60)
+ axis.label.set_text(r"$\theta = 60^{\circ}$")
+ axis.label.set_visible(True)
+
+
+See the first example of this page.
+
+Current Limitations and TODO's
+==============================
+
+The code need more refinement. Here is a incomplete list of issues and TODO's
+
+* No easy way to support a user customized tick location (for
+ curvelinear grid). A new Locator class needs to be created.
+
+* FloatingAxis may have coordinate limits, e.g., a floating axis of x
+ = 0, but y only spans from 0 to 1.
+
+* The location of axislabel of FloatingAxis needs to be optionally
+ given as a coordinate value. ex, a floating axis of x=0 with label at y=1
Modified: trunk/matplotlib/examples/axes_grid/demo_floating_axis.py
===================================================================
--- trunk/matplotlib/examples/axes_grid/demo_floating_axis.py 2009-06-27 13:13:50 UTC (rev 7243)
+++ trunk/matplotlib/examples/axes_grid/demo_floating_axis.py 2009-06-29 15:11:00 UTC (rev 7244)
@@ -1,6 +1,5 @@
"""
-A floating axes for curvelinear grid.
-.
+An experimental support for curvelinear grid.
"""
@@ -8,6 +7,7 @@
"""
polar projection, but in a rectangular box.
"""
+ global ax1
import numpy as np
import mpl_toolkits.axes_grid.angle_helper as angle_helper
from matplotlib.projections import PolarAxes
@@ -40,19 +40,18 @@
ax1 = SubplotHost(fig, 1, 1, 1, grid_helper=grid_helper)
-
fig.add_subplot(ax1)
# Now creates floating axis
- grid_helper = ax1.get_grid_helper()
+ #grid_helper = ax1.get_grid_helper()
# floating axis whose first coordinate (theta) is fixed at 60
- ax1.axis["lat"] = axis = grid_helper.new_floating_axis(0, 60, axes=ax1)
+ ax1.axis["lat"] = axis = ax1.new_floating_axis(0, 60)
axis.label.set_text(r"$\theta = 60^{\circ}$")
axis.label.set_visible(True)
# floating axis whose second coordinate (r) is fixed at 6
- ax1.axis["lon"] = axis = grid_helper.new_floating_axis(1, 6, axes=ax1)
+ ax1.axis["lon"] = axis = ax1.new_floating_axis(1, 6)
axis.label.set_text(r"$r = 6$")
ax1.set_aspect(1.)
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/grid_helper_curvelinear.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/grid_helper_curvelinear.py 2009-06-27 13:13:50 UTC (rev 7243)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/grid_helper_curvelinear.py 2009-06-29 15:11:00 UTC (rev 7244)
@@ -14,7 +14,7 @@
"""
Helper class for a fixed axis.
"""
-
+
def __init__(self, grid_helper, side, nth_coord_ticks=None):
"""
nth_coord = along which coordinate value varies.
@@ -100,7 +100,7 @@
lon_factor,
lon_levs)
- grid_info["lat_labels"] = grid_finder.tick_formatter1("bottom",
+ grid_info["lat_labels"] = grid_finder.tick_formatter2("bottom",
lat_factor,
lat_levs)
@@ -321,7 +321,7 @@
if label_direction is None:
label_direction = "top"
-
+
_helper = FloatingAxisArtistHelper(self, nth_coord,
value,
label_direction=label_direction,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-06-27 13:13:53
|
Revision: 7243
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7243&view=rev
Author: jswhit
Date: 2009-06-27 13:13:50 +0000 (Sat, 27 Jun 2009)
Log Message:
-----------
use np.loadtxt instead of mlab.load
Modified Paths:
--------------
trunk/toolkits/basemap/examples/plotmap_oo.py
Modified: trunk/toolkits/basemap/examples/plotmap_oo.py
===================================================================
--- trunk/toolkits/basemap/examples/plotmap_oo.py 2009-06-26 18:11:32 UTC (rev 7242)
+++ trunk/toolkits/basemap/examples/plotmap_oo.py 2009-06-27 13:13:50 UTC (rev 7243)
@@ -14,15 +14,14 @@
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from mpl_toolkits.basemap import Basemap, shiftgrid
from matplotlib.figure import Figure
-import numpy
+import numpy as np
import matplotlib.cm as cm
-from matplotlib.mlab import load
# read in topo data (on a regular lat/lon grid)
# longitudes go from 20 to 380.
-topoin = load('etopo20data.gz')
-lons = load('etopo20lons.gz')
-lats = load('etopo20lats.gz')
+topoin = np.loadtxt('etopo20data.gz')
+lons = np.loadtxt('etopo20lons.gz')
+lats = np.loadtxt('etopo20lats.gz')
# shift data so lons go from -180 to 180 instead of 20 to 380.
topoin,lons = shiftgrid(180.,topoin,lons,start=False)
@@ -59,9 +58,9 @@
m.drawstates()
# draw parallels and meridians.
# label on left, right and bottom of map.
-parallels = numpy.arange(0.,80,20.)
+parallels = np.arange(0.,80,20.)
m.drawparallels(parallels,labels=[1,1,0,1])
-meridians = numpy.arange(10.,360.,30.)
+meridians = np.arange(10.,360.,30.)
m.drawmeridians(meridians,labels=[1,1,0,1])
# set title.
ax.set_title('ETOPO Topography - Lambert Conformal Conic')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-06-26 18:12:34
|
Revision: 7242
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7242&view=rev
Author: jswhit
Date: 2009-06-26 18:11:32 +0000 (Fri, 26 Jun 2009)
Log Message:
-----------
fix url
Modified Paths:
--------------
trunk/toolkits/basemap/examples/plotsst.py
Modified: trunk/toolkits/basemap/examples/plotsst.py
===================================================================
--- trunk/toolkits/basemap/examples/plotsst.py 2009-06-25 05:17:10 UTC (rev 7241)
+++ trunk/toolkits/basemap/examples/plotsst.py 2009-06-26 18:11:32 UTC (rev 7242)
@@ -12,7 +12,7 @@
date = datetime.datetime(int(date[0:4]),int(date[4:6]),int(date[6:8]))
print date
# open dataset.
-dataset = NetCDFFile('http://nomads.ncdc.noaa.gov/thredds/dodsC/oisst/totalAagg')
+dataset = NetCDFFile('http://nomads.ncdc.noaa.gov/thredds/dodsC/oisst/totalAgg')
# find index of desired time.
time = dataset.variables['time']
nt = date2index(date, time, calendar='standard')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-06-25 05:17:11
|
Revision: 7241
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7241&view=rev
Author: leejjoon
Date: 2009-06-25 05:17:10 +0000 (Thu, 25 Jun 2009)
Log Message:
-----------
axes_grid: doc update
Modified Paths:
--------------
trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/index.rst
trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/overview.rst
trunk/matplotlib/examples/axes_grid/demo_floating_axis.py
trunk/matplotlib/lib/mpl_toolkits/axes_grid/grid_helper_curvelinear.py
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/index.rst
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/index.rst 2009-06-25 04:57:48 UTC (rev 7240)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/index.rst 2009-06-25 05:17:10 UTC (rev 7241)
@@ -11,3 +11,4 @@
overview.rst
axes_divider.rst
+ axislines.rst
Modified: trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/overview.rst
===================================================================
--- trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/overview.rst 2009-06-25 04:57:48 UTC (rev 7240)
+++ trunk/matplotlib/doc/mpl_toolkits/axes_grid/users/overview.rst 2009-06-25 05:17:10 UTC (rev 7241)
@@ -388,3 +388,13 @@
.. plot:: mpl_toolkits/axes_grid/figures/inset_locator_demo2.py
:include-source:
+
+Curvelinear Grid
+================
+
+You can draw a cuvelinear grid and ticks. Also a floating axis can be
+created. See :ref:`axislines-manual` for more details.
+
+.. plot:: mpl_toolkits/axes_grid/figures/demo_floating_axis.py
+
+
Modified: trunk/matplotlib/examples/axes_grid/demo_floating_axis.py
===================================================================
--- trunk/matplotlib/examples/axes_grid/demo_floating_axis.py 2009-06-25 04:57:48 UTC (rev 7240)
+++ trunk/matplotlib/examples/axes_grid/demo_floating_axis.py 2009-06-25 05:17:10 UTC (rev 7241)
@@ -40,9 +40,6 @@
ax1 = SubplotHost(fig, 1, 1, 1, grid_helper=grid_helper)
- # make ticklabels of right and top axis visible.
- for axis in ax1.axis.values():
- axis.toggle(all=False)
fig.add_subplot(ax1)
Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/grid_helper_curvelinear.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/axes_grid/grid_helper_curvelinear.py 2009-06-25 04:57:48 UTC (rev 7240)
+++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/grid_helper_curvelinear.py 2009-06-25 05:17:10 UTC (rev 7241)
@@ -315,10 +315,13 @@
def new_floating_axis(self, nth_coord,
value,
tick_direction="in",
- label_direction="top",
+ label_direction=None,
axes=None,
):
+ if label_direction is None:
+ label_direction = "top"
+
_helper = FloatingAxisArtistHelper(self, nth_coord,
value,
label_direction=label_direction,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-06-25 04:57:50
|
Revision: 7240
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7240&view=rev
Author: leejjoon
Date: 2009-06-25 04:57:48 +0000 (Thu, 25 Jun 2009)
Log Message:
-----------
legend supports CircleCollection.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/collections.py
trunk/matplotlib/lib/matplotlib/legend.py
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py 2009-06-24 21:01:53 UTC (rev 7239)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2009-06-25 04:57:48 UTC (rev 7240)
@@ -995,6 +995,10 @@
self._paths = [mpath.Path.unit_circle()]
__init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
+ def get_sizes(self):
+ "return sizes of circles"
+ return self._sizes
+
def draw(self, renderer):
# sizes is the area of the circle circumscribing the polygon
# in points^2
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py 2009-06-24 21:01:53 UTC (rev 7239)
+++ trunk/matplotlib/lib/matplotlib/legend.py 2009-06-25 04:57:48 UTC (rev 7240)
@@ -31,7 +31,8 @@
from matplotlib.font_manager import FontProperties
from matplotlib.lines import Line2D
from matplotlib.patches import Patch, Rectangle, Shadow, FancyBboxPatch
-from matplotlib.collections import LineCollection, RegularPolyCollection
+from matplotlib.collections import LineCollection, RegularPolyCollection, \
+ CircleCollection
from matplotlib.transforms import Bbox, BboxBase, TransformedBbox, BboxTransformTo
from matplotlib.offsetbox import HPacker, VPacker, TextArea, DrawingArea
@@ -439,7 +440,8 @@
# manually set their transform to the self.get_transform().
for handle in handles:
- if isinstance(handle, RegularPolyCollection):
+ if isinstance(handle, RegularPolyCollection) or \
+ isinstance(handle, CircleCollection):
npoints = self.scatterpoints
else:
npoints = self.numpoints
@@ -531,6 +533,31 @@
p.set_clip_path(None)
handle_list.append(p)
+ elif isinstance(handle, CircleCollection):
+
+ ydata = height*self._scatteryoffsets
+
+ size_max, size_min = max(handle.get_sizes()),\
+ min(handle.get_sizes())
+ # we may need to scale these sizes by "markerscale"
+ # attribute. But other handle types does not seem
+ # to care about this attribute and it is currently ignored.
+ if self.scatterpoints < 4:
+ sizes = [.5*(size_max+size_min), size_max,
+ size_min]
+ else:
+ sizes = (size_max-size_min)*np.linspace(0,1,self.scatterpoints)+size_min
+
+ p = type(handle)(sizes,
+ offsets=zip(xdata_marker,ydata),
+ transOffset=self.get_transform(),
+ )
+
+ p.update_from(handle)
+ p.set_figure(self.figure)
+ p.set_clip_box(None)
+ p.set_clip_path(None)
+ handle_list.append(p)
else:
handle_list.append(None)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-06-24 21:04:26
|
Revision: 7239
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7239&view=rev
Author: jdh2358
Date: 2009-06-24 21:01:53 +0000 (Wed, 24 Jun 2009)
Log Message:
-----------
some tweaks to csv2rec and rec2csv
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/doc/api/api_changes.rst
trunk/matplotlib/doc/devel/release_guide.rst
trunk/matplotlib/lib/matplotlib/mlab.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-06-24 18:53:48 UTC (rev 7238)
+++ trunk/matplotlib/CHANGELOG 2009-06-24 21:01:53 UTC (rev 7239)
@@ -1,3 +1,8 @@
+2009-06-24 Add withheader option to mlab.rec2csv and changed
+ use_mrecords default to False in mlab.csv2rec since this is
+ partially broken - JDH
+
+
2009-06-24 backend_agg.draw_marker quantizes the main path (as in the
draw_path). - JJL
Modified: trunk/matplotlib/doc/api/api_changes.rst
===================================================================
--- trunk/matplotlib/doc/api/api_changes.rst 2009-06-24 18:53:48 UTC (rev 7238)
+++ trunk/matplotlib/doc/api/api_changes.rst 2009-06-24 21:01:53 UTC (rev 7239)
@@ -1,3 +1,4 @@
+
===========
API Changes
===========
@@ -20,7 +21,10 @@
Changes beyond 0.98.x
=====================
-* Axes instanaces no longer have a "frame" attribute. Instead, use the
+* changed use_mrecords default to False in mlab.csv2rec since this is
+ partially broken
+
+* Axes instances no longer have a "frame" attribute. Instead, use the
new "spines" attribute. Spines is a dictionary where the keys are
the names of the spines (e.g. 'left','right' and so on) and the
values are the artists that draw the spines. For normal
Modified: trunk/matplotlib/doc/devel/release_guide.rst
===================================================================
--- trunk/matplotlib/doc/devel/release_guide.rst 2009-06-24 18:53:48 UTC (rev 7238)
+++ trunk/matplotlib/doc/devel/release_guide.rst 2009-06-24 21:01:53 UTC (rev 7239)
@@ -64,16 +64,18 @@
or off any platform specific build options you need. Importantly,
you also need to make sure that you delete the :file:`build` dir
after any changes to file:`setup.cfg` before rebuilding since cruft
- in the :file:`build` dir can get carried along. I will add this to
- the devel release notes,
+ in the :file:`build` dir can get carried along.
* on windows, unix2dos the rc file
* We have a Makefile for the OS X builds in the mpl source dir
:file:`release/osx`, so use this to prepare the OS X releases.
+* We have a Makefile for the win32 mingw builds in the mpl source dir
+ :file:`release/win32` which you can use this to prepare the windows
+ releases, but this is currently broken for python2.6 as described at
+ http://www.nabble.com/binary-installers-for-python2.6--libpng-segfault%2C-MSVCR90.DLL-and-%09mingw-td23971661.html
-
.. _release-candidate-testing:
Release candidate testing:
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py 2009-06-24 18:53:48 UTC (rev 7238)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2009-06-24 21:01:53 UTC (rev 7239)
@@ -2052,7 +2052,7 @@
def csv2rec(fname, comments='#', skiprows=0, checkrows=0, delimiter=',',
converterd=None, names=None, missing='', missingd=None,
- use_mrecords=True):
+ use_mrecords=False):
"""
Load data from comma/space/tab delimited file in *fname* into a
numpy record array and return the record array.
@@ -2560,7 +2560,7 @@
def rec2csv(r, fname, delimiter=',', formatd=None, missing='',
- missingd=None):
+ missingd=None, withheader=True):
"""
Save the data from numpy recarray *r* into a
comma-/space-/tab-delimited file. The record array dtype names
@@ -2569,6 +2569,9 @@
*fname*: can be a filename or a file handle. Support for gzipped
files is automatic, if the filename ends in '.gz'
+ *withheader*: if withheader is False, do not write the attribute
+ names in the first row
+
.. seealso::
:func:`csv2rec`
@@ -2595,7 +2598,8 @@
fh, opened = cbook.to_filehandle(fname, 'w', return_opened=True)
writer = csv.writer(fh, delimiter=delimiter)
header = r.dtype.names
- writer.writerow(header)
+ if withheader:
+ writer.writerow(header)
# Our list of specials for missing values
mvals = []
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-06-24 18:54:33
|
Revision: 7238
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7238&view=rev
Author: jswhit
Date: 2009-06-24 18:53:48 +0000 (Wed, 24 Jun 2009)
Log Message:
-----------
add code to import pyplot as necessary
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-06-24 18:18:55 UTC (rev 7237)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-06-24 18:53:48 UTC (rev 7238)
@@ -2543,6 +2543,9 @@
Other \**kwargs passed on to matplotlib.pyplot.scatter.
"""
ax = kwargs.pop('ax', None) or self._check_ax()
+ # if ax kwarg not supplied, and ax attribute not set, import pyplot.
+ if self.ax is None and kwargs.pop('ax', None) is None:
+ import matplotlib.pyplot as plt
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
h = kwargs.pop('hold',None)
@@ -2611,6 +2614,9 @@
returns an matplotlib.image.AxesImage instance.
"""
ax = kwargs.pop('ax', None) or self._check_ax()
+ # if ax kwarg not supplied, and ax attribute not set, import pyplot.
+ if self.ax is None and kwargs.pop('ax', None) is None:
+ import matplotlib.pyplot as plt
kwargs['extent']=(self.llcrnrx,self.urcrnrx,self.llcrnry,self.urcrnry)
# use origin='lower', unless overridden.
if not kwargs.has_key('origin'):
@@ -2653,6 +2659,9 @@
Other \**kwargs passed on to matplotlib.pyplot.pcolor.
"""
ax = kwargs.pop('ax', None) or self._check_ax()
+ # if ax kwarg not supplied, and ax attribute not set, import pyplot.
+ if self.ax is None and kwargs.pop('ax', None) is None:
+ import matplotlib.pyplot as plt
# make x,y masked arrays
# (masked where data is outside of projection limb)
x = ma.masked_values(np.where(x > 1.e20,1.e20,x), 1.e20)
@@ -2691,6 +2700,9 @@
Other \**kwargs passed on to matplotlib.pyplot.pcolormesh.
"""
ax = kwargs.pop('ax', None) or self._check_ax()
+ # if ax kwarg not supplied, and ax attribute not set, import pyplot.
+ if self.ax is None and kwargs.pop('ax', None) is None:
+ import matplotlib.pyplot as plt
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
h = kwargs.pop('hold',None)
@@ -2725,6 +2737,9 @@
Other \*args and \**kwargs passed on to matplotlib.pyplot.contour.
"""
ax = kwargs.pop('ax', None) or self._check_ax()
+ # if ax kwarg not supplied, and ax attribute not set, import pyplot.
+ if self.ax is None and kwargs.pop('ax', None) is None:
+ import matplotlib.pyplot as plt
# make sure x is monotonically increasing - if not,
# print warning suggesting that the data be shifted in longitude
# with the shiftgrid function.
@@ -2789,6 +2804,9 @@
Other \*args and \**kwargs passed on to matplotlib.pyplot.scatter.
"""
ax = kwargs.pop('ax', None) or self._check_ax()
+ # if ax kwarg not supplied, and ax attribute not set, import pyplot.
+ if self.ax is None and kwargs.pop('ax', None) is None:
+ import matplotlib.pyplot as plt
# make sure x is monotonically increasing - if not,
# print warning suggesting that the data be shifted in longitude
# with the shiftgrid function.
@@ -2850,6 +2868,9 @@
Other \*args and \**kwargs passed on to matplotlib.pyplot.quiver.
"""
ax = kwargs.pop('ax', None) or self._check_ax()
+ # if ax kwarg not supplied, and ax attribute not set, import pyplot.
+ if self.ax is None and kwargs.pop('ax', None) is None:
+ import matplotlib.pyplot as plt
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
h = kwargs.pop('hold',None)
@@ -2887,6 +2908,9 @@
you have %s""" % _matplotlib_version)
raise NotImplementedError(msg)
ax = kwargs.pop('ax', None) or self._check_ax()
+ # if ax kwarg not supplied, and ax attribute not set, import pyplot.
+ if self.ax is None and kwargs.pop('ax', None) is None:
+ import matplotlib.pyplot as plt
# allow callers to override the hold state by passing hold=True|False
b = ax.ishold()
h = kwargs.pop('hold',None)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|