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






Showing 2 results of 2

From: <lee...@us...> - 2009年05月14日 06:28:11
Revision: 7102
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7102&view=rev
Author: leejjoon
Date: 2009年05月14日 06:27:58 +0000 (2009年5月14日)
Log Message:
-----------
An optional offset and bbox support in restore_bbox
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
 trunk/matplotlib/src/_backend_agg.cpp
 trunk/matplotlib/src/_backend_agg.h
Added Paths:
-----------
 trunk/matplotlib/examples/animation/animation_blit_gtk2.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2009年05月14日 04:00:38 UTC (rev 7101)
+++ trunk/matplotlib/CHANGELOG	2009年05月14日 06:27:58 UTC (rev 7102)
@@ -1,4 +1,7 @@
 ======================================================================
+2009年05月13日 An optional offset and bbox support in restore_bbox. 
+ Add animation_blit_gtk2.py. -JJL
+
 2009年05月13日 psfrag in backend_ps now uses baseline-alignment 
 when preview.sty is used ((default is
 bottom-alignment). Also, a small api imporvement 
Added: trunk/matplotlib/examples/animation/animation_blit_gtk2.py
===================================================================
--- trunk/matplotlib/examples/animation/animation_blit_gtk2.py	 (rev 0)
+++ trunk/matplotlib/examples/animation/animation_blit_gtk2.py	2009年05月14日 06:27:58 UTC (rev 7102)
@@ -0,0 +1,167 @@
+#!/usr/bin/env python
+
+"""
+This example utlizes restore_region with optional bbox and xy
+arguments. The plot is continuously shifted to the left. Instead of
+drawing everything again, the plot is saved (copy_from_bbox) and
+restored with offset by the amount of the shift. And only newly
+exposed area is drawn. This technique may reduce drawing time for some cases.
+"""
+
+import time
+
+import gtk, gobject
+
+import matplotlib
+matplotlib.use('GTKAgg')
+
+import numpy as np
+import matplotlib.pyplot as plt
+
+class UpdateLine(object):
+ def get_bg_bbox(self):
+ 
+ return self.ax.bbox.padded(-3)
+ 
+ def __init__(self, canvas, ax):
+ self.cnt = 0
+ self.canvas = canvas
+ self.ax = ax
+
+ self.prev_time = time.time()
+ self.start_time = self.prev_time
+ self.prev_pixel_offset = 0.
+ 
+
+ self.x0 = 0
+ self.phases = np.random.random_sample((20,)) * np.pi * 2
+ self.line, = ax.plot([], [], "-", animated=True, lw=2)
+
+ self.point, = ax.plot([], [], "ro", animated=True, lw=2)
+
+ self.ax.set_ylim(-1.1, 1.1)
+
+ self.background1 = None
+
+ cmap = plt.cm.jet
+ from itertools import cycle
+ self.color_cycle = cycle(cmap(np.arange(cmap.N)))
+
+
+ def save_bg(self):
+ self.background1 = self.canvas.copy_from_bbox(self.ax.get_figure().bbox)
+
+ self.background2 = self.canvas.copy_from_bbox(self.get_bg_bbox())
+
+
+ def get_dx_data(self, dx_pixel):
+ tp = self.ax.transData.inverted().transform_point
+ x0, y0 = tp((0, 0))
+ x1, y1 = tp((dx_pixel, 0))
+ return (x1-x0)
+
+
+ def restore_background_shifted(self, dx_pixel):
+ """
+ restore bacground shifted by dx in data coordinate. This only
+ works if the data coordinate system is linear.
+ """
+
+ # restore the clean slate background
+ self.canvas.restore_region(self.background1)
+
+ # restore subregion (x1+dx, y1, x2, y2) of the second bg 
+ # in a offset position (x1-dx, y1)
+ x1, y1, x2, y2 = self.background2.get_extents()
+ self.canvas.restore_region(self.background2,
+ bbox=(x1+dx_pixel, y1, x2, y2),
+ xy=(x1-dx_pixel, y1))
+
+ return dx_pixel
+
+ def on_draw(self, *args):
+ self.save_bg()
+ return False
+ 
+ def update_line(self, *args):
+
+ if self.background1 is None:
+ return True
+ 
+ cur_time = time.time()
+ pixel_offset = int((cur_time - self.start_time)*100.)
+ dx_pixel = pixel_offset - self.prev_pixel_offset
+ self.prev_pixel_offset = pixel_offset
+ dx_data = self.get_dx_data(dx_pixel) #cur_time - self.prev_time)
+ 
+ x0 = self.x0
+ self.x0 += dx_data
+ self.prev_time = cur_time
+
+ self.ax.set_xlim(self.x0-2, self.x0+0.1)
+
+
+ # restore background which will plot lines from previous plots
+ self.restore_background_shifted(dx_pixel) #x0, self.x0)
+ # This restores lines between [x0-2, x0]
+
+
+
+ self.line.set_color(self.color_cycle.next())
+
+ # now plot line segment within [x0, x0+dx_data], 
+ # Note that we're only plotting a line between [x0, x0+dx_data].
+ xx = np.array([x0, self.x0])
+ self.line.set_xdata(xx)
+
+ # the for loop below could be improved by using collection.
+ [(self.line.set_ydata(np.sin(xx+p)),
+ self.ax.draw_artist(self.line)) \
+ for p in self.phases]
+
+ self.background2 = canvas.copy_from_bbox(self.get_bg_bbox())
+
+ self.point.set_xdata([self.x0])
+
+ [(self.point.set_ydata(np.sin([self.x0+p])),
+ self.ax.draw_artist(self.point)) \
+ for p in self.phases]
+
+
+ self.ax.draw_artist(self.ax.xaxis)
+ self.ax.draw_artist(self.ax.yaxis)
+
+ self.canvas.blit(self.ax.get_figure().bbox)
+
+
+ dt = (time.time()-tstart)
+ if dt>15:
+ # print the timing info and quit
+ print 'FPS:' , self.cnt/dt
+ gtk.main_quit()
+ raise SystemExit
+
+ self.cnt += 1
+ return True
+
+
+plt.rcParams["text.usetex"] = False
+fig = plt.figure()
+
+ax = fig.add_subplot(111)
+ax.xaxis.set_animated(True)
+ax.yaxis.set_animated(True)
+canvas = fig.canvas
+
+fig.subplots_adjust(left=0.2, bottom=0.2)
+canvas.draw()
+
+# for profiling
+tstart = time.time()
+
+ul = UpdateLine(canvas, ax)
+gobject.idle_add(ul.update_line)
+
+canvas.mpl_connect('draw_event', ul.on_draw)
+
+plt.show()
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py	2009年05月14日 04:00:38 UTC (rev 7101)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py	2009年05月14日 06:27:58 UTC (rev 7102)
@@ -33,7 +33,7 @@
 from matplotlib.ft2font import FT2Font, LOAD_FORCE_AUTOHINT
 from matplotlib.mathtext import MathTextParser
 from matplotlib.path import Path
-from matplotlib.transforms import Bbox
+from matplotlib.transforms import Bbox, BboxBase
 
 from _backend_agg import RendererAgg as _RendererAgg
 from matplotlib import _png
@@ -65,7 +65,6 @@
 self.draw_quad_mesh = self._renderer.draw_quad_mesh
 self.draw_image = self._renderer.draw_image
 self.copy_from_bbox = self._renderer.copy_from_bbox
- self.restore_region = self._renderer.restore_region
 self.tostring_rgba_minimized = self._renderer.tostring_rgba_minimized
 self.mathtext_parser = MathTextParser('Agg')
 
@@ -239,7 +238,39 @@
 # with the Agg backend
 return True
 
+ def restore_region(self, region, bbox=None, xy=None):
+ """
+ restore the saved region. if bbox (instance of BboxBase, or
+ its extents) is given, only the region specified by the bbox
+ will be restored. *xy* (a tuple of two floasts) optionally
+ specify the new position (of the LLC of the originally region,
+ not the LLC of the bbox) that the region will be restored.
 
+ >>> region = renderer.copy_from_bbox()
+ >>> x1, y1, x2, y2 = region.get_extents()
+ >>> renderer.restore_region(region, bbox=(x1+dx, y1, x2, y2),
+ xy=(x1-dx, y1))
+ 
+ """
+ if bbox is not None or xy is not None:
+ if bbox is None:
+ x1, y1, x2, y2 = region.get_extents()
+ elif isinstance(bbox, BboxBase):
+ x1, y1, x2, y2 = bbox.extents
+ else:
+ x1, y1, x2, y2 = bbox
+
+ if xy is None:
+ ox, oy = x1, y1
+ else:
+ ox, oy = xy
+
+ self._renderer.restore_region2(region, x1, y1, x2, y2, ox, oy)
+
+ else:
+ self._renderer.restore_region(region)
+
+
 def new_figure_manager(num, *args, **kwargs):
 """
 Create a new figure manager instance
@@ -269,9 +300,9 @@
 renderer = self.get_renderer()
 return renderer.copy_from_bbox(bbox)
 
- def restore_region(self, region):
+ def restore_region(self, region, bbox=None, xy=None):
 renderer = self.get_renderer()
- return renderer.restore_region(region)
+ return renderer.restore_region(region, bbox, xy)
 
 def draw(self):
 """
@@ -334,3 +365,4 @@
 renderer.width, renderer.height,
 filename_or_obj, self.figure.dpi)
 renderer.dpi = original_dpi
+
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp	2009年05月14日 04:00:38 UTC (rev 7101)
+++ trunk/matplotlib/src/_backend_agg.cpp	2009年05月14日 06:27:58 UTC (rev 7102)
@@ -104,6 +104,18 @@
 return Py::Object();
 }
 
+Py::Object BufferRegion::get_extents(const Py::Tuple &args) {
+ args.verify_length(0);
+
+ Py::Tuple extents(4);
+ extents[0] = Py::Int(rect.x1);
+ extents[1] = Py::Int(rect.y1);
+ extents[2] = Py::Int(rect.x2);
+ extents[3] = Py::Int(rect.y2);
+
+ return extents;
+}
+
 Py::Object BufferRegion::to_string_argb(const Py::Tuple &args) {
 // owned=true to prevent memory leak
 Py_ssize_t length;
@@ -426,6 +438,49 @@
 return Py::Object();
 }
 
+// Restore the part of the saved region with offsets
+Py::Object
+RendererAgg::restore_region2(const Py::Tuple& args) {
+ //copy BufferRegion to buffer
+ args.verify_length(7);
+
+
+
+ int x(0),y(0), xx1(0),yy1(0), xx2(0), yy2(0);
+ try {
+ xx1 = Py::Int( args[1] );
+ yy1 = Py::Int( args[2] );
+ xx2 = Py::Int( args[3] );
+ yy2 = Py::Int( args[4] );
+ x = Py::Int( args[5] );
+ y = Py::Int( args[6] );
+ }
+ catch (Py::TypeError) {
+ throw Py::TypeError("Invalid input arguments to draw_text_image");
+ }
+
+
+ BufferRegion* region = static_cast<BufferRegion*>(args[0].ptr());
+
+ if (region->data==NULL)
+ throw Py::ValueError("Cannot restore_region from NULL data");
+
+ agg::rect_i rect(xx1-region->rect.x1, (yy1-region->rect.y1), 
+		 xx2-region->rect.x1, (yy2-region->rect.y1));
+
+
+ agg::rendering_buffer rbuf;
+ rbuf.attach(region->data,
+	 region->width,
+	 region->height,
+	 region->stride);
+
+ rendererBase.copy_from(rbuf, &rect, x, y);
+
+ return Py::Object();
+}
+
+
 bool RendererAgg::render_clippath(const Py::Object& clippath, const agg::trans_affine& clippath_trans) {
 typedef agg::conv_transform<PathIterator> transformed_path_t;
 typedef agg::conv_curve<transformed_path_t> curve_t;
@@ -1717,6 +1772,9 @@
 add_varargs_method("set_y", &BufferRegion::set_y,
 		 "set_y(y)");
 
+ add_varargs_method("get_extents", &BufferRegion::get_extents,
+		 "get_extents()");
+
 add_varargs_method("to_string", &BufferRegion::to_string,
 		 "to_string()");
 add_varargs_method("to_string_argb", &BufferRegion::to_string_argb,
@@ -1759,6 +1817,8 @@
 		 "copy_from_bbox(bbox)");
 add_varargs_method("restore_region", &RendererAgg::restore_region,
 		 "restore_region(region)");
+ add_varargs_method("restore_region2", &RendererAgg::restore_region2,
+ 		 "restore_region(region, x1, y1, x2, y2, x3, y3)");
 }
 
 extern "C"
Modified: trunk/matplotlib/src/_backend_agg.h
===================================================================
--- trunk/matplotlib/src/_backend_agg.h	2009年05月14日 04:00:38 UTC (rev 7101)
+++ trunk/matplotlib/src/_backend_agg.h	2009年05月14日 06:27:58 UTC (rev 7102)
@@ -87,6 +87,8 @@
 Py::Object set_x(const Py::Tuple &args);
 Py::Object set_y(const Py::Tuple &args);
 
+ Py::Object get_extents(const Py::Tuple &args);
+
 Py::Object to_string(const Py::Tuple &args);
 Py::Object to_string_argb(const Py::Tuple &args);
 static void init_type(void);
@@ -174,6 +176,7 @@
 
 Py::Object copy_from_bbox(const Py::Tuple & args);
 Py::Object restore_region(const Py::Tuple & args);
+ Py::Object restore_region2(const Py::Tuple & args);
 
 virtual ~RendererAgg();
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <lee...@us...> - 2009年05月14日 04:00:41
Revision: 7101
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7101&view=rev
Author: leejjoon
Date: 2009年05月14日 04:00:38 +0000 (2009年5月14日)
Log Message:
-----------
psfrag in backend_ps now uses baseline-alignment when preview.sty is used
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
 trunk/matplotlib/lib/matplotlib/offsetbox.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2009年05月13日 19:59:16 UTC (rev 7100)
+++ trunk/matplotlib/CHANGELOG	2009年05月14日 04:00:38 UTC (rev 7101)
@@ -1,4 +1,9 @@
 ======================================================================
+2009年05月13日 psfrag in backend_ps now uses baseline-alignment 
+ when preview.sty is used ((default is
+ bottom-alignment). Also, a small api imporvement 
+ in OffsetBox-JJL
+
 2009年05月13日 When the x-coordinate of a line is monotonically
 increasing, it is now automatically clipped at
 the stage of generating the transformed path in
@@ -6,7 +11,7 @@
 panning when one is looking at a short segment of
 a long time series, for example. - EF
 
-2009年05月11日 aspect=1 in log-log plot gives square decades.
+2009年05月11日 aspect=1 in log-log plot gives square decades. -JJL
 
 2009年05月08日 clabel takes new kwarg, rightside_up; if False, labels
 will not be flipped to keep them rightside-up. This
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py	2009年05月13日 19:59:16 UTC (rev 7100)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py	2009年05月14日 04:00:38 UTC (rev 7101)
@@ -537,8 +537,6 @@
 """
 w, h, bl = self.get_text_width_height_descent(s, prop, ismath)
 fontsize = prop.get_size_in_points()
- corr = 0#w/2*(fontsize-10)/10
- pos = _nums_to_str(x-corr, y)
 thetext = 'psmarker%d' % self.textcnt
 color = '%1.3f,%1.3f,%1.3f'% gc.get_rgb()[:3]
 fontcmd = {'sans-serif' : r'{\sffamily %s}',
@@ -546,7 +544,17 @@
 rcParams['font.family'], r'{\rmfamily %s}')
 s = fontcmd % s
 tex = r'\color[rgb]{%s} %s' % (color, s)
- self.psfrag.append(r'\psfrag{%s}[bl][bl][1][%f]{\fontsize{%f}{%f}%s}'%(thetext, angle, fontsize, fontsize*1.25, tex))
+
+ corr = 0#w/2*(fontsize-10)/10
+ if rcParams['text.latex.preview']:
+ # use baseline alignment!
+ pos = _nums_to_str(x-corr, y+bl)
+ self.psfrag.append(r'\psfrag{%s}[Bl][Bl][1][%f]{\fontsize{%f}{%f}%s}'%(thetext, angle, fontsize, fontsize*1.25, tex))
+ else:
+ # stick to the bottom alignment, but this may give incorrect baseline some times.
+ pos = _nums_to_str(x-corr, y)
+ self.psfrag.append(r'\psfrag{%s}[bl][bl][1][%f]{\fontsize{%f}{%f}%s}'%(thetext, angle, fontsize, fontsize*1.25, tex))
+
 ps = """\
 gsave
 %(pos)s moveto
Modified: trunk/matplotlib/lib/matplotlib/offsetbox.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/offsetbox.py	2009年05月13日 19:59:16 UTC (rev 7100)
+++ trunk/matplotlib/lib/matplotlib/offsetbox.py	2009年05月14日 04:00:38 UTC (rev 7101)
@@ -782,11 +782,14 @@
 explicitly specify the bbox_to_anchor.
 """
 
+ zorder = 5 # zorder of the legend
+
 def __init__(self, loc,
 pad=0.4, borderpad=0.5,
 child=None, prop=None, frameon=True,
 bbox_to_anchor=None,
- bbox_transform=None):
+ bbox_transform=None,
+ **kwargs):
 """
 loc is a string or an integer specifying the legend location.
 The valid location codes are::
@@ -819,7 +822,7 @@
 
 """
 
- super(AnchoredOffsetbox, self).__init__()
+ super(AnchoredOffsetbox, self).__init__(**kwargs)
 
 self.set_bbox_to_anchor(bbox_to_anchor, bbox_transform)
 self.set_child(child)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 2 results of 2

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 によって変換されたページ (->オリジナル) /