SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

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
S M T W T F S





1
2
(4)
3
(2)
4
(9)
5
6
7
8
9
10
11
(6)
12
13
14
15
16
(10)
17
(1)
18
19
(1)
20
21
22
(3)
23
24
25
(2)
26
27
28
(3)
29
(5)
30
31






Showing 3 results of 3

From: <jd...@us...> - 2010年01月28日 21:46:19
Revision: 8100
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8100&view=rev
Author: jdh2358
Date: 2010年01月28日 21:46:12 +0000 (2010年1月28日)
Log Message:
-----------
added drabbable state to legend -- thanks Adam Fraser
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/legend.py
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py	2010年01月28日 20:37:46 UTC (rev 8099)
+++ trunk/matplotlib/lib/matplotlib/legend.py	2010年01月28日 21:46:12 UTC (rev 8100)
@@ -38,6 +38,51 @@
 from matplotlib.offsetbox import HPacker, VPacker, TextArea, DrawingArea
 
 
+class DraggableLegend:
+ """helper code for a draggable legend -- see Legend.draggable"""
+
+ def __init__(self, legend):
+ self.legend = legend
+ self.gotLegend = False
+
+ c1 = legend.figure.canvas.mpl_connect('motion_notify_event', self.on_motion)
+ c2 = legend.figure.canvas.mpl_connect('pick_event', self.on_pick)
+ c3 = legend.figure.canvas.mpl_connect('button_release_event', self.on_release)
+ legend.set_picker(self.my_legend_picker)
+ self.cids = [c1, c2, c3]
+
+ def on_motion(self, evt):
+ if self.gotLegend:
+ dx = evt.x - self.mouse_x
+ dy = evt.y - self.mouse_y
+ loc_in_canvas = self.legend_x + dx, self.legend_y + dy
+ loc_in_norm_axes = self.legend.parent.transAxes.inverted().transform_point(loc_in_canvas)
+ self.legend._loc = tuple(loc_in_norm_axes)
+ self.legend.figure.canvas.draw()
+
+ def my_legend_picker(self, legend, evt):
+ return self.legend.legendPatch.contains(evt)
+
+ def on_pick(self, evt):
+ legend = self.legend
+ if evt.artist == legend:
+ bbox = self.legend.get_window_extent()
+ self.mouse_x = evt.mouseevent.x
+ self.mouse_y = evt.mouseevent.y
+ self.legend_x = bbox.xmin
+ self.legend_y = bbox.ymin
+ self.gotLegend = 1
+
+ def on_release(self, event):
+ if self.gotLegend:
+ self.gotLegend = False
+
+ def disconnect(self):
+ 'disconnect the callbacks'
+ for cid in self.cids:
+ self.legend.figure.canvas.mpl_disconnect(cid)
+
+
 class Legend(Artist):
 """
 Place a legend on the axes at location loc. Labels are a
@@ -182,7 +227,7 @@
 self.texts = []
 self.legendHandles = []
 self._legend_title_box = None
- 
+
 localdict = locals()
 
 for name in propnames:
@@ -284,7 +329,7 @@
 
 # We use FancyBboxPatch to draw a legend frame. The location
 # and size of the box will be updated during the drawing time.
- 
+
 self.legendPatch = FancyBboxPatch(
 xy=(0.0, 0.0), width=1., height=1.,
 facecolor=rcParams["axes.facecolor"],
@@ -316,6 +361,7 @@
 
 self._last_fontsize_points = self._fontsize
 
+ self._draggable = None
 
 def _set_artist_props(self, a):
 """
@@ -584,7 +630,7 @@
 textbox = TextArea(lab, textprops=label_prop,
 multilinebaseline=True, minimumdescent=True)
 text_list.append(textbox._text)
- 
+
 labelboxes.append(textbox)
 
 handlebox = DrawingArea(width=self.handlelength*fontsize,
@@ -597,7 +643,7 @@
 handleboxes.append(handlebox)
 
 
- if len(handleboxes) > 0: 
+ if len(handleboxes) > 0:
 
 # We calculate number of lows in each column. The first
 # (num_largecol) columns will have (nrows+1) rows, and remaing
@@ -613,7 +659,7 @@
 [nrows] * num_smallcol)
 else:
 largecol, smallcol = [], []
- 
+
 handle_label = safezip(handleboxes, labelboxes)
 columnbox = []
 for i0, di in largecol+smallcol:
@@ -889,3 +935,16 @@
 return ox, oy
 
 
+ def draggable(self):
+ """
+ toggle the draggable state; if on, you can drag the legend on
+ the canvas. The DraggableLegend helper class is returned
+ """
+ if self._draggable is not None:
+ self._draggable.disconnect()
+ self._draggable = None
+ else:
+
+ self._draggable = DraggableLegend(self)
+
+ return self._draggable
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <lee...@us...> - 2010年01月28日 20:37:55
Revision: 8099
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8099&view=rev
Author: leejjoon
Date: 2010年01月28日 20:37:46 +0000 (2010年1月28日)
Log Message:
-----------
experimental support of Image._image_skew_coordinate
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/image.py
Added Paths:
-----------
 trunk/matplotlib/examples/api/demo_affine_image.py
Added: trunk/matplotlib/examples/api/demo_affine_image.py
===================================================================
--- trunk/matplotlib/examples/api/demo_affine_image.py	 (rev 0)
+++ trunk/matplotlib/examples/api/demo_affine_image.py	2010年01月28日 20:37:46 UTC (rev 8099)
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+
+
+"""
+For the backends that supports draw_image with optional affine
+transform (e.g., ps backend), the image of the output should
+have its boundary matches the red rectangles.
+"""
+
+import numpy as np
+import matplotlib.cm as cm
+import matplotlib.mlab as mlab
+import matplotlib.pyplot as plt
+import matplotlib.transforms as mtransforms
+
+def get_image():
+ delta = 0.25
+ x = y = np.arange(-3.0, 3.0, delta)
+ X, Y = np.meshgrid(x, y)
+ Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
+ Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
+ Z = Z2-Z1 # difference of Gaussians
+ return Z
+
+def imshow_affine(ax, z, *kl, **kwargs):
+ im = ax.imshow(z, *kl, **kwargs)
+ x1, x2, y1, y2 = im.get_extent()
+ im._image_skew_coordinate = (x2, y1)
+ return im
+
+
+if 1:
+ ax = plt.subplot(111)
+ Z = get_image()
+ im = imshow_affine(ax, Z, interpolation='nearest', cmap=cm.jet,
+ origin='lower', extent=[-2, 4, -3, 2])
+
+ trans_data2 = mtransforms.Affine2D().rotate_deg(30) + ax.transData
+ im.set_transform(trans_data2)
+
+ # display intended extent of the image
+ x1, x2, y1, y2 = im.get_extent()
+ x3, y3 = x2, y1
+
+ ax.plot([x1, x2, x2, x1, x1], [y1, y1, y2, y2, y1], "r--", lw=3,
+ transform=trans_data2)
+
+ ax.set_xlim(-3, 5)
+ ax.set_ylim(-4, 4)
+
+ plt.savefig("demo_affine_image")
Modified: trunk/matplotlib/lib/matplotlib/image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/image.py	2010年01月28日 19:09:20 UTC (rev 8098)
+++ trunk/matplotlib/lib/matplotlib/image.py	2010年01月28日 20:37:46 UTC (rev 8099)
@@ -25,6 +25,7 @@
 from matplotlib._image import *
 
 from matplotlib.transforms import BboxBase
+import matplotlib.transforms as mtransforms
 
 class _AxesImageBase(martist.Artist, cm.ScalarMappable):
 zorder = 0
@@ -96,6 +97,12 @@
 
 self._imcache = None
 
+ # this is an expetimental attribute, if True, unsampled image
+ # will be drawn using the affine transform that are
+ # appropriately skewed so that the given postition
+ # corresponds to the actual position in the coordinate. -JJL
+ self._image_skew_coordinate = None
+
 self.update(kwargs)
 
 def get_size(self):
@@ -204,6 +211,36 @@
 return im, xmin, ymin, dxintv, dyintv, sx, sy
 
 
+ @staticmethod
+ def _get_rotate_and_skew_transform(x1, y1, x2, y2, x3, y3):
+ """
+ Retuen a transform that does
+ (x1, y1) -> (x1, y1)
+ (x2, y2) -> (x2, y2)
+ (x2, y1) -> (x3, y3)
+
+ It was intended to derive a skew transform that preserve the
+ lower-left corner (x1, y1) and top-right corner(x2,y2), but
+ change the the lower-right-corner(x2, y1) to a new position
+ (x3, y3).
+ """
+ tr1 = mtransforms.Affine2D()
+ tr1.translate(-x1, -y1)
+ x2a, y2a = tr1.transform_point((x2, y2))
+ x3a, y3a = tr1.transform_point((x3, y3))
+
+ inv_mat = 1./(x2a*y3a-y2a*x3a) * np.mat([[y3a, -y2a],[-x3a, x2a]])
+
+ a, b = (inv_mat * np.mat([[x2a], [x2a]])).flat
+ c, d = (inv_mat * np.mat([[y2a], [0]])).flat
+
+ tr2 = mtransforms.Affine2D.from_values(a, c, b, d, 0, 0)
+
+ tr = (tr1 + tr2 + mtransforms.Affine2D().translate(x1, y1)).inverted().get_affine()
+
+ return tr
+
+
 def _draw_unsampled_image(self, renderer, gc):
 """
 draw unsampled image. The renderer should support a draw_image method
@@ -227,13 +264,25 @@
 im._url = self.get_url()
 
 trans = self.get_transform() #axes.transData
- xx1, yy1 = trans.transform_non_affine((xmin, ymin))
- xx2, yy2 = trans.transform_non_affine((xmin+dxintv, ymin+dyintv))
+ xy = trans.transform_non_affine([(xmin, ymin),
+ (xmin+dxintv, ymin+dyintv)])
+ xx1, yy1 = xy[0]
+ xx2, yy2 = xy[1]
 
- renderer.draw_image(gc, xx1, yy1, im, xx2-xx1, yy2-yy1,
- trans.get_affine())
+ if self._image_skew_coordinate:
+ # skew the image when required.
+ x_lrc, y_lrc = self._image_skew_coordinate
+ xy = trans.transform_non_affine([(x_lrc, y_lrc)])
+ xx3, yy3 = xy[0]
 
+ tr_rotate_skew = self._get_rotate_and_skew_transform(xx1, yy1, xx2, yy2, xx3, yy3)
+ tr = tr_rotate_skew+trans.get_affine()
+ else:
+ tr = trans.get_affine()
 
+ renderer.draw_image(gc, xx1, yy1, im, xx2-xx1, yy2-yy1, tr)
+
+
 def _check_unsampled_image(self, renderer):
 """
 return True if the image is better to be drawn unsampled.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ry...@us...> - 2010年01月28日 19:09:28
Revision: 8098
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8098&view=rev
Author: ryanmay
Date: 2010年01月28日 19:09:20 +0000 (2010年1月28日)
Log Message:
-----------
Support setting zorder keyword for ContourSet.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/contour.py
Modified: trunk/matplotlib/lib/matplotlib/contour.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/contour.py	2010年01月25日 20:31:41 UTC (rev 8097)
+++ trunk/matplotlib/lib/matplotlib/contour.py	2010年01月28日 19:09:20 UTC (rev 8098)
@@ -695,10 +695,13 @@
 
 paths = self._make_paths(segs, kinds)
 
+ # Default zorder taken from Collection
+ zorder = kwargs.get('zorder', 1)
 col = collections.PathCollection(paths,
 antialiaseds = (self.antialiased,),
 edgecolors= 'none',
- alpha=self.alpha)
+ alpha=self.alpha,
+ zorder=zorder)
 self.ax.add_collection(col)
 self.collections.append(col)
 else:
@@ -710,10 +713,14 @@
 nseg = len(nlist)//2
 segs = nlist[:nseg]
 #kinds = nlist[nseg:]
+
+ # Default zorder taken from LineCollection
+ zorder = kwargs.get('zorder', 2)
 col = collections.LineCollection(segs,
 linewidths = width,
 linestyle = lstyle,
- alpha=self.alpha)
+ alpha=self.alpha,
+ zorder=zorder)
 
 col.set_label('_nolegend_')
 self.ax.add_collection(col, False)
@@ -1228,4 +1235,3 @@
 ymin = lc[imin,1]
 
 return (conmin,segmin,imin,xmin,ymin,dmin)
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 3 results of 3

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /