Revision: 3934 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3934&view=rev Author: mdboom Date: 2007-10-11 08:42:53 -0700 (Thu, 11 Oct 2007)
Log Message: ----------- Continued progress getting more examples to work. Working examples (with TkAgg backend only) are marked in PASSED_DEMOS for the curious. Modified Paths: -------------- branches/transforms/examples/histogram_demo_canvasagg.py branches/transforms/examples/line_collection2.py branches/transforms/examples/pick_event_demo.py branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/axis.py branches/transforms/lib/matplotlib/collections.py branches/transforms/lib/matplotlib/colorbar.py branches/transforms/lib/matplotlib/colors.py branches/transforms/lib/matplotlib/figure.py branches/transforms/lib/matplotlib/image.py branches/transforms/lib/matplotlib/legend.py branches/transforms/lib/matplotlib/lines.py branches/transforms/lib/matplotlib/mathtext.py branches/transforms/lib/matplotlib/patches.py branches/transforms/lib/matplotlib/ticker.py branches/transforms/lib/matplotlib/transforms.py branches/transforms/src/_backend_agg.cpp branches/transforms/src/_backend_agg.h Added Paths: ----------- branches/transforms/PASSED_DEMOS Added: branches/transforms/PASSED_DEMOS =================================================================== --- branches/transforms/PASSED_DEMOS (rev 0) +++ branches/transforms/PASSED_DEMOS 2007-10-11 15:42:53 UTC (rev 3934) @@ -0,0 +1,210 @@ +accented_text.py O +agg_buffer_to_array.py O +agg_oo.py O +agg_resize.py [BROKEN IN TRUNK] +agg_test.py +alignment_test.py O +animation_blit_fltk.py +animation_blit.py +animation_blit_qt4.py +animation_blit_qt.py +animation_blit_tk.py +animation_blit_wx.py +anim.py O [BUT SLOWER] +annotation_demo.py O +anscombe.py O +arctest.py O +arrow_demo.py O +axes_demo.py O +axes_props.py [SOMETHING FUNNY ABOUT DASHED LINES] +axhspan_demo.py O +axis_equal_demo.py O +backend_driver.py +barchart_demo.py O +barcode_demo.py O +barh_demo.py [BROKEN IN TRUNK] +bar_stacked.py O +boxplot_demo.py O +break.py O +broken_barh.py O +clippath_test.py O +clippedline.py O +collections_demo.py -- [NEEDS ADDITIONAL WORK] +colorbar_only.py O +color_by_yvalue.py O +color_demo.py O +colours.py [???] +contour_demo.py +contourf_demo.py +contour_image.py +coords_demo.py O +coords_report.py O +csd_demo.py O +cursor_demo.py O +custom_figure_class.py [EXCEPT FOR PS OUTPUT] +customize_rc.py +custom_ticker1.py O +dannys_example.py [REQUIRES NUMERIC] +dash_control.py O +dashpointlabel.py O +dashtick.py +data_browser.py O +data_helper.py [N/A] +date_demo1.py O +date_demo2.py O +date_demo_convert.py O [PASSES] +date_demo_rrule.py O [PASSES] +date_index_formatter.py O [PASSES] +dynamic_collection.py O +dynamic_demo.py [GTK] +dynamic_demo_wx.py [WX] +dynamic_image_gtkagg.py +dynamic_image_wxagg2.py +dynamic_image_wxagg.py +ellipse_demo.py O +ellipse_rotated.py O +embedding_in_gtk2.py +embedding_in_gtk3.py +embedding_in_gtk.py +embedding_in_qt4.py +embedding_in_qt.py +embedding_in_tk2.py +embedding_in_tk.py +embedding_in_wx2.py +embedding_in_wx3.py +embedding_in_wx4.py +embedding_in_wx.py +errorbar_demo.py O +errorbar_limits.py O +figimage_demo.py O +figlegend_demo.py [HORRIBLY BROKEN] +figtext.py O +fill_between_posneg.py O +fill_between.py O +fill_demo2.py O +fill_demo.py O +fill_spiral.py O +finance_demo.py O +font_indexing.py O +fonts_demo_kw.py O +fonts_demo.py O +font_table_ttf.py [N/A] +ftface_props.py [N/A] +ganged_plots.py O +glyph_to_path.py [Requires PIL] +gradient_bar.py O +gtk_spreadsheet.py +hatch_demo.py [Requires PS] +histogram_demo_canvasagg.py [???] +histogram_demo.py O +image_demo2.py O +image_demo3.py [Requires PIL] +image_demo.py O +image_interp.py O +image_masked.py O [Whew!] +image_origin.py O +image_slices_viewer.py [BROKEN ON TRUNK] +__init__.py +integral_demo.py O +interactive2.py [N/A] +interactive.py [N/A] +interp_demo.py O +invert_axes.py O +keypress_demo.py [BROKEN IN TRUNK] +lasso_demo.py O +layer_images.py O +legend_auto.py [WEIRD z-order problem in figure 10] +legend_demo2.py O +legend_demo.py O +legend_scatter.py O +line_collection2.py O +line_collection.py O +lineprops_dialog_gtk.py +line_styles.py O +load_converter.py O +loadrec.py O +log_bar.py O +log_demo.py O +logo.py O +log_test.py O +major_minor_demo1.py O +major_minor_demo2.py O +masked_demo.py O +mathtext_demo.py O +mathtext_examples.py O +mathtext_wx.py +matplotlib_icon.py [N/A] +matshow.py O +movie_demo.py O +mpl_with_glade.py [N/A] +mri_demo.py O +mri_with_eeg.py +multi_image.py O +multiline.py O +multiple_figs_demo.py O +newscalarformatter_demo.py O +pcolor_demo2.py O +pcolor_demo.py O +pcolor_log.py O +pcolor_nonuniform.py O +pcolor_small.py O +pick_event_demo2.py +pick_event_demo.py +pie_demo.py +plotfile_demo.py +polar_bar.py +polar_demo.py +polar_legend.py +polar_scatter.py +poly_editor.py +poormans_contour.py +printing_in_wx.py +print_stdout.py +psd_demo.py +pstest.py +pylab_with_gtk.py +pythonic_matplotlib.py +quadmesh_demo.py +quiver_demo.py +rc_traits.py +scatter_custom_symbol.py +scatter_demo2.py +scatter_demo.py +scatter_masked.py +scatter_profile.py +scatter_star_poly.py +set_and_get.py +shared_axis_across_figures.py +shared_axis_demo.py +simple3d_oo.py +simple3d.py +simple_plot_fps.py +simple_plot.py +specgram_demo.py +spy_demos.py +stem_plot.py +step_demo.py +stock_demo.py +strip_chart_demo.py +subplot_demo.py +subplots_adjust.py +subplot_toolbar.py +system_monitor.py +table_demo.py +tex_demo.py +text_handles.py +text_rotation.py +text_themes.py +tex_unicode_demo.py +toggle_images.py +to_numeric.py +transoffset.py +two_scales.py +unicode_demo.py +vertical_ticklabels.py +vline_demo.py +webapp_demo.py +wxcursor_demo.py +xcorr_demo.py +zoom_window.py +zorder_demo.py Modified: branches/transforms/examples/histogram_demo_canvasagg.py =================================================================== --- branches/transforms/examples/histogram_demo_canvasagg.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/examples/histogram_demo_canvasagg.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -11,7 +11,6 @@ """ from matplotlib.backends.backend_agg import FigureCanvasAgg from matplotlib.figure import Figure -from matplotlib.axes import Subplot from matplotlib.mlab import normpdf from numpy.random import randn import numpy @@ -45,7 +44,7 @@ # get the figure dimensions for creating bitmaps or numpy arrays, # etc. -l,b,w,h = fig.bbox.get_bounds() +l,b,w,h = fig.bbox.bounds w, h = int(w), int(h) if 0: Modified: branches/transforms/examples/line_collection2.py =================================================================== --- branches/transforms/examples/line_collection2.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/examples/line_collection2.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -23,7 +23,7 @@ # See matplotlib.collections.LineCollection for more information line_segments = LineCollection([zip(x,y) for y in ys], # Make a sequence of x,y pairs linewidths = (0.5,1,1.5,2), - linestyle = 'solid') + linestyles = 'solid') line_segments.set_array(x) ax.add_collection(line_segments) fig = gcf() Modified: branches/transforms/examples/pick_event_demo.py =================================================================== --- branches/transforms/examples/pick_event_demo.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/examples/pick_event_demo.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -93,7 +93,7 @@ print 'onpick1 line:', zip(nx.take(xdata, ind), nx.take(ydata, ind)) elif isinstance(event.artist, Rectangle): patch = event.artist - print 'onpick1 patch:', patch.get_verts() + print 'onpick1 patch:', patch.get_path() elif isinstance(event.artist, Text): text = event.artist print 'onpick1 text:', text.get_text() Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/lib/matplotlib/axes.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -480,8 +480,7 @@ if isinstance(rect, mtransforms.Bbox): self._position = rect else: - warnings.warn("Passing non-bbox as rect to Axes") - mtransforms.Bbox.from_lbwh(*rect) + self._position = mtransforms.Bbox.from_lbwh(*rect) self._originalPosition = self._position.frozen() self.set_axes(self) self.set_aspect('auto') @@ -596,7 +595,7 @@ def get_xaxis_text2_transform(self, pad_pixels): return (self._xaxis_transform + mtransforms.Affine2D().translate(0, pad_pixels), - "top", "center") + "bottom", "center") def get_yaxis_transform(self): return self._yaxis_transform @@ -609,7 +608,7 @@ def get_yaxis_text2_transform(self, pad_pixels): return (self._yaxis_transform + mtransforms.Affine2D().translate(pad_pixels, 0), - "center", "right") + "center", "left") def _update_transScale(self): self.transScale.set( @@ -643,8 +642,8 @@ self._position.set(pos) if which in ('both', 'original'): self._originalPosition.set(pos) + - def _set_artist_props(self, a): 'set the boilerplate props for artists added to axes' a.set_figure(self.figure) @@ -1083,7 +1082,8 @@ def _update_patch_limits(self, p): 'update the datalimits for patch p' xys = self._get_verts_in_data_coords( - p.get_transform(), p.get_path().vertices) + p.get_data_transform(), + p.get_patch_transform().transform(p.get_path().vertices)) self.update_datalim(xys) @@ -1240,11 +1240,11 @@ for im in self.images if im.get_visible()] - im = mimage.from_images(self.bbox.height()*mag, - self.bbox.width()*mag, + im = mimage.from_images(self.bbox.height*mag, + self.bbox.width*mag, ims) im.is_grayscale = False - l, b, w, h = self.bbox.get_bounds() + l, b, w, h = self.bbox.bounds # composite images need special args so they will not # respect z-order for now renderer.draw_image(l, b, im, self.bbox) Modified: branches/transforms/lib/matplotlib/axis.py =================================================================== --- branches/transforms/lib/matplotlib/axis.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/lib/matplotlib/axis.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -1290,14 +1290,13 @@ else: if not len(bboxes2): - right = self.axes.bbox.xmax() + right = self.axes.bbox.xmax else: + bbox = Bbox.union(bboxes2) + right = bbox.xmax - bbox = bbox_union(bboxes2) - right = bbox.xmax() + self.label.set_position( (right+self.LABELPAD*self.figure.dpi/72.0, y)) - self.label.set_position( (right+self.LABELPAD*self.figure.dpi.get()/72.0, y)) - def _update_offset_text_position(self, bboxes, bboxes2): """ Update the offset_text position based on the sequence of bounding Modified: branches/transforms/lib/matplotlib/collections.py =================================================================== --- branches/transforms/lib/matplotlib/collections.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/lib/matplotlib/collections.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -23,6 +23,9 @@ from matplotlib.backends._backend_agg import get_path_collection_extents, \ point_in_path_collection +# MGDTODO: Treat facecolors and edgecolors as numpy arrays always +# and then update draw_path_collection to use the array interface + class Collection(artist.Artist, cm.ScalarMappable): """ Base class for Collections. Must be subclassed to be usable. @@ -58,7 +61,6 @@ """ _offsets = npy.zeros((1, 2)) _transOffset = transforms.IdentityTransform() - _transforms = [None] zorder = 1 @@ -163,9 +165,9 @@ self.update_scalarmappable() - #print 'calling renderer draw line collection' clippath, clippath_trans = self.get_transformed_clip_path_and_affine() + # MGDTODO: This may benefit from using TransformedPath if not transform.is_affine: paths = [transform.transform_path_non_affine(path) for path in paths] transform = transform.get_affine() @@ -185,10 +187,19 @@ Returns T/F, dict(ind=itemlist), where every item in itemlist contains the event. """ if callable(self._contains): return self._contains(self,mouseevent) + + transform = self.get_transform() + paths = self.get_paths() + if not transform.is_affine: + paths = [transform.transform_path_non_affine(path) for path in paths] + transform = transform.get_affine() + + # MGDTODO: Don't pick when outside of clip path / clip box ind = point_in_path_collection( mouseevent.x, mouseevent.y, self._pickradius, - self.get_transform(), self._paths, self._transforms, self._offsets, - self._offsetTrans, self._facecolors) + transform.frozen(), paths, self.get_transforms(), + npy.asarray(self._offsets, npy.float_), + self._transOffset.frozen(), len(self._facecolors)) return len(ind)>0,dict(ind=ind) # MGDTODO: Update @@ -233,7 +244,7 @@ def set_pickradius(self,pickradius): self.pickradius = 5 def get_pickradius(self): return self.pickradius - def set_linewidth(self, lw): + def set_linewidths(self, lw): """ Set the linewidth(s) for the collection. lw can be a scalar or a sequence; if it is a sequence the patches will cycle through the @@ -242,9 +253,8 @@ ACCEPTS: float or sequence of floats """ self._linewidths = self._get_value(lw) - def set_linewidths(self, lw): - self.set_linewidth(lw) - + set_linewidth = set_linewidths + def set_linestyles(self, ls): """ Set the linestyles(s) for the collection. @@ -274,6 +284,7 @@ raise ValueError('Do not know how to convert %s to dashes'%ls) self._linestyles = dashes + set_dashes = set_linestyle = set_linestyles def set_color(self, c): """ @@ -295,8 +306,7 @@ ACCEPTS: matplotlib color arg or sequence of rgba tuples """ self._facecolors = _colors.colorConverter.to_rgba_list(c) - def set_facecolors(self, c): - self.set_facecolor(c) + set_facecolors = set_facecolor def set_edgecolor(self, c): """ @@ -308,10 +318,10 @@ """ if c == 'None': self._linewidths = (0.0,) + self._edgecolors = npy.array([]) else: self._edgecolors = _colors.colorConverter.to_rgba_list(c) - def set_edgecolors(self, c): - self.set_edgecolor(c) + set_edgecolors = set_edgecolor def set_alpha(self, alpha): """ @@ -324,29 +334,30 @@ except TypeError: raise TypeError('alpha must be a float') else: artist.Artist.set_alpha(self, alpha) - self._facecolors = [(r,g,b,alpha) for r,g,b,a in self._facecolors] - if cbook.is_string_like(self._edgecolors) and self._edgecolors != 'None': - self._edgecolors = [(r,g,b,alpha) for r,g,b,a in self._edgecolors] + self._facecolors[:, 3] = alpha + self._edgecolors[:, 3] = alpha - def get_linewidth(self): + def get_linewidths(self): return self._linewidths + get_linewidth = get_linewidths - def get_linestyle(self): + def get_linestyles(self): return self._linestyles - - def get_dashes(self): - return self._linestyles + get_dashes = get_linestyle = get_linestyles def update_scalarmappable(self): """ - If the scalar mappable array is not none, update facecolors + If the scalar mappable array is not none, update colors from scalar data """ #print 'update_scalarmappable: self._A', self._A if self._A is None: return if len(self._A.shape)>1: raise ValueError('PatchCollections can only map rank 1 arrays') - self._facecolors = self.to_rgba(self._A, self._alpha) + if len(self._facecolors): + self._facecolors = self.to_rgba(self._A, self._alpha) + else: + self._edgecolors = self.to_rgba(self._A, self._alpha) #print self._facecolors @@ -673,6 +684,8 @@ if antialiaseds is None: antialiaseds = (mpl.rcParams['lines.antialiased'],) self.set_linestyles(linestyles) + colors = _colors.colorConverter.to_rgba_list(colors) + Collection.__init__( self, edgecolors=colors, @@ -686,7 +699,7 @@ pickradius=pickradius, **kwargs) - self._facecolors = [None] + self._facecolors = npy.array([]) self.set_segments(segments) def get_paths(self): Modified: branches/transforms/lib/matplotlib/colorbar.py =================================================================== --- branches/transforms/lib/matplotlib/colorbar.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/lib/matplotlib/colorbar.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -319,9 +319,9 @@ else: intv = self.vmin, self.vmax locator.create_dummy_axis() + formatter.create_dummy_axis() locator.set_view_interval(*intv) locator.set_data_interval(*intv) - formatter.create_dummy_axis() formatter.set_view_interval(*intv) formatter.set_data_interval(*intv) b = npy.array(locator()) @@ -580,18 +580,18 @@ shrink = kw.pop('shrink', 1.0) aspect = kw.pop('aspect', 20) #pb = transforms.PBox(parent.get_position()) - pb = transforms.PBox(parent.get_position(original=True)) + pb = parent.get_position(original=True).frozen() if orientation == 'vertical': pad = kw.pop('pad', 0.05) x1 = 1.0-fraction pb1, pbx, pbcb = pb.splitx(x1-pad, x1) - pbcb.shrink(1.0, shrink).anchor('C') + pbcb = pbcb.shrunk(1.0, shrink).anchored('C', pbcb) anchor = (0.0, 0.5) panchor = (1.0, 0.5) else: pad = kw.pop('pad', 0.15) pbcb, pbx, pb1 = pb.splity(fraction, fraction+pad) - pbcb.shrink(shrink, 1.0).anchor('C') + pbcb = pbcb.shrunk(shrink, 1.0).anchored('C', pbcb) aspect = 1.0/aspect anchor = (0.5, 1.0) panchor = (0.5, 0.0) Modified: branches/transforms/lib/matplotlib/colors.py =================================================================== --- branches/transforms/lib/matplotlib/colors.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/lib/matplotlib/colors.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -316,7 +316,7 @@ If the sequence is a list, the list items are changed in place. """ try: - return [self.to_rgba(c, alpha)] + result = [self.to_rgba(c, alpha)] except ValueError: # If c is a list it must be maintained as the same list # with modified items so that items can be appended to @@ -325,7 +325,8 @@ c = list(c) for i, cc in enumerate(c): c[i] = self.to_rgba(cc, alpha) # change in place - return c + result = c + return npy.asarray(result, npy.float_) colorConverter = ColorConverter() Modified: branches/transforms/lib/matplotlib/figure.py =================================================================== --- branches/transforms/lib/matplotlib/figure.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/lib/matplotlib/figure.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -623,11 +623,11 @@ mag = renderer.get_image_magnification() ims = [(im.make_image(mag), im.ox*mag, im.oy*mag) for im in self.images] - im = _image.from_images(self.bbox.height()*mag, - self.bbox.width()*mag, + im = _image.from_images(self.bbox.height * mag, + self.bbox.width * mag, ims) im.is_grayscale = False - l, b, w, h = self.bbox.get_bounds() + l, b, w, h = self.bbox.bounds renderer.draw_image(l, b, im, self.bbox) Modified: branches/transforms/lib/matplotlib/image.py =================================================================== --- branches/transforms/lib/matplotlib/image.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/lib/matplotlib/image.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -332,8 +332,8 @@ if self._A is None: raise RuntimeError('You must first set the image array') - x0, y0, v_width, v_height = self.axes.viewLim.get_bounds() - l, b, width, height = self.axes.bbox.get_bounds() + x0, y0, v_width, v_height = self.axes.viewLim.bounds + l, b, width, height = self.axes.bbox.bounds width *= magnification height *= magnification im = _image.pcolor(self._Ax, self._Ay, self._A, Modified: branches/transforms/lib/matplotlib/legend.py =================================================================== --- branches/transforms/lib/matplotlib/legend.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/lib/matplotlib/legend.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -38,7 +38,7 @@ def line_cuts_bbox(line, bbox): """ Return True if and only if line cuts bbox. """ - minx, miny, width, height = bbox.get_bounds() + minx, miny, width, height = bbox.bounds maxx = minx + width maxy = miny + height @@ -343,31 +343,27 @@ bboxes = [] lines = [] - inv = ax.transAxes.inverse_xy_tup + inv = ax.transAxes.inverted().transform for handle in ax.lines: assert isinstance(handle, Line2D) - - xdata = handle.get_xdata(orig=False) - ydata = handle.get_ydata(orig=False) + data = handle.get_xydata() trans = handle.get_transform() - xt, yt = trans.numerix_x_y(xdata, ydata) - - # XXX need a special method in transform to do a list of verts - averts = [inv(v) for v in zip(xt, yt)] + tdata = trans.transform(data) + averts = inv(tdata) lines.append(averts) for handle in ax.patches: assert isinstance(handle, Patch) - verts = handle.get_verts() + path = handle.get_path() trans = handle.get_transform() - tverts = trans.seq_xy_tups(verts) + tpath = trans.transform_path(path) + tverts = tpath.vertices + averts = inv(tverts) - averts = [inv(v) for v in tverts] - - bbox = unit_bbox() - bbox.update(averts, True) + bbox = Bbox.unit() + bbox.update_from_data_xy(averts, True) bboxes.append(bbox) for handle in ax.collections: @@ -445,22 +441,19 @@ consider = [self._loc_to_axes_coords(x, width, height) for x in range(1, len(self.codes))] - tx, ty = self.legendPatch.xy + tx, ty = self.legendPatch.get_x(), self.legendPatch.get_y() candidates = [] for l, b in consider: legendBox = Bbox.from_lbwh(l, b, width, height) badness = 0 badness = legendBox.count_contains(verts) - ox, oy = l-tx, b-ty - for bbox in bboxes: - if legendBox.overlaps(bbox): - badness += 1 - + badness += legendBox.count_overlaps(bboxes) for line in lines: if line_cuts_bbox(line, legendBox): badness += 1 + ox, oy = l-tx, b-ty if badness == 0: return ox, oy @@ -564,6 +557,4 @@ self._offset(ox, oy) - - #artist.kwdocd['Legend'] = kwdoc(Legend) Modified: branches/transforms/lib/matplotlib/lines.py =================================================================== --- branches/transforms/lib/matplotlib/lines.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/lib/matplotlib/lines.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -350,16 +350,15 @@ self._picker = p def get_window_extent(self, renderer): - bbox = Bbox() - bbox.update_from_data(self.get_transform().transform(self._xy)) - + bbox = Bbox.unit() + bbox.update_from_data_xy(self.get_transform().transform(self._xy), + ignore=True) # correct for marker size, if any if self._marker is not None: - ms = self._markersize / 72.0 * self.figure.dpi - bbox = Bbox(bbox.get_points() + [[-ms/2.0, ms/2.0]]) + ms = (self._markersize / 72.0 * self.figure.dpi) * 0.5 + bbox = Bbox(bbox.get_points() + [[-ms, -ms], [ms, ms]]) return bbox - def set_axes(self, ax): Artist.set_axes(self, ax) if ax.xaxis is not None: Modified: branches/transforms/lib/matplotlib/mathtext.py =================================================================== --- branches/transforms/lib/matplotlib/mathtext.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/lib/matplotlib/mathtext.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -672,7 +672,8 @@ _slanted_symbols = Set(r"\int \oint".split()) def _get_glyph(self, fontname, sym, fontsize): - if fontname in self.fontmap and latex_to_bakoma.has_key(sym): + use_default = fontname == 'default' and len(sym) == 1 + if latex_to_bakoma.has_key(sym) and not use_default: basename, num = latex_to_bakoma[sym] slanted = (basename == "cmmi10") or sym in self._slanted_symbols cached_font = self._get_font(basename) Modified: branches/transforms/lib/matplotlib/patches.py =================================================================== --- branches/transforms/lib/matplotlib/patches.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/lib/matplotlib/patches.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -114,6 +114,9 @@ self._combined_transform = self.get_patch_transform() + \ artist.Artist.get_transform(self) + def get_data_transform(self): + return artist.Artist.get_transform(self) + def get_patch_transform(self): return transforms.IdentityTransform() @@ -307,8 +310,8 @@ g = rho*g b = rho*b - self.set_facecolor((r,g,b)) - self.set_edgecolor((r,g,b)) + self.set_facecolor((r,g,b,0.5)) + self.set_edgecolor((r,g,b,0.5)) def get_path(self): return self.patch.get_path() @@ -960,7 +963,7 @@ pad = props.pop('pad', 4) pad = renderer.points_to_pixels(pad) bbox = artist.get_window_extent(renderer) - l,b,w,h = bbox.get_bounds() + l,b,w,h = bbox.bounds l-=pad/2. b-=pad/2. w+=pad Modified: branches/transforms/lib/matplotlib/ticker.py =================================================================== --- branches/transforms/lib/matplotlib/ticker.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/lib/matplotlib/ticker.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -118,8 +118,8 @@ axis = None class DummyAxis: def __init__(self): - self.dataLim = mtransforms.Bbox - self.viewLim = mtransforms.Bbox + self.dataLim = mtransforms.Bbox.unit() + self.viewLim = mtransforms.Bbox.unit() def get_view_interval(self): return self.viewLim.intervalx @@ -137,7 +137,8 @@ self.axis = axis def create_dummy_axis(self): - self.axis = self.DummyAxis() + if self.axis is None: + self.axis = self.DummyAxis() def set_view_interval(self, vmin, vmax): self.axis.set_view_interval(vmin, vmax) @@ -229,8 +230,8 @@ def __call__(self, x, pos=None): 'Return the format for tick val x at position pos' - self.verify_intervals() - d = abs(self.viewInterval.span()) + xmin, xmax = self.axis.get_view_interval() + d = abs(xmax - xmin) return self.pprint_val(x,d) @@ -322,7 +323,7 @@ if self.offset > 0: offsetStr = '+' + offsetStr if self.orderOfMagnitude: if self._usetex or self._useMathText: - sciNotStr = r'{\times}'+self.format_data(10**self.orderOfMagnitude) + sciNotStr = r'\times'+self.format_data(10**self.orderOfMagnitude) else: sciNotStr = u'\xd7'+'1e%d'% self.orderOfMagnitude if self._useMathText: @@ -451,8 +452,8 @@ def __call__(self, x, pos=None): 'Return the format for tick val x at position pos' - self.verify_intervals() - d = abs(self.viewInterval.span()) + vmin, vmax = self.axis.get_view_interval() + d = abs(vmax - vmin) b=self._base # only label the decades fx = math.log(x)/math.log(b) @@ -769,10 +770,7 @@ def __call__(self): 'Return the locations of the ticks' - - self.verify_intervals() - - vmin, vmax = self.viewInterval.get_bounds() + vmin, vmax = self.axis.get_view_interval() if vmax<vmin: vmin, vmax = vmax, vmin vmin = self._base.ge(vmin) @@ -786,10 +784,8 @@ Set the view limits to the nearest multiples of base that contain the data """ + dmin, dmax = self.axis.get_data_interval() - self.verify_intervals() - dmin, dmax = self.dataInterval.get_bounds() - vmin = self._base.le(dmin) vmax = self._base.ge(dmax) if vmin==vmax: Modified: branches/transforms/lib/matplotlib/transforms.py =================================================================== --- branches/transforms/lib/matplotlib/transforms.py 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/lib/matplotlib/transforms.py 2007-10-11 15:42:53 UTC (rev 3934) @@ -268,20 +268,24 @@ def contains(self, x, y): return self.containsx(x) and self.containsy(y) - def overlapsx(self, other): - xmin, xmax = other.intervalx - return self.containsx(xmin) \ - or self.containsx(xmax) + def overlaps(self, other): + ax1, ay1, ax2, ay2 = self._get_lbrt() + bx1, by1, bx2, by2 = other._get_lbrt() - def overlapsy(self, other): - ymin, ymax = other.intervaly - return self.containsy(ymin) \ - or self.containsy(ymax) + if ax2 < ax1: + ax2, ax1 = ax1, ax2 + if ay2 < ay1: + ay2, ay1 = ay1, ay2 + if bx2 < bx1: + bx2, bx1 = bx1, bx2 + if by2 < by1: + by2, by1 = by1, by2 + + return not ((bx2 < ax1) or + (by2 < ay1) or + (bx1 > ax2) or + (by1 > ay2)) - def overlaps(self, other): - return self.overlapsx(other) \ - and self.overlapsy(other) - def fully_containsx(self, x): xmin, xmax = self.intervalx return ((xmin < xmax @@ -298,20 +302,24 @@ return self.fully_containsx(x) \ and self.fully_containsy(y) - def fully_overlapsx(self, other): - xmin, xmax = other.intervalx - return self.fully_containsx(xmin) \ - or self.fully_containsx(xmax) - - def fully_overlapsy(self, other): - ymin, ymax = other.intervaly - return self.fully_containsy(ymin) \ - or self.fully_containsy(ymax) - def fully_overlaps(self, other): - return self.fully_overlapsx(other) and \ - self.fully_overlapsy(other) + ax1, ay1, ax2, ay2 = self._get_lbrt() + bx1, by1, bx2, by2 = other._get_lbrt() + if ax2 < ax1: + ax2, ax1 = ax1, ax2 + if ay2 < ay1: + ay2, ay1 = ay1, ay2 + if bx2 < bx1: + bx2, bx1 = bx1, bx2 + if by2 < by1: + by2, by1 = by1, by2 + + return not ((bx2 <= ax1) or + (by2 <= ay1) or + (bx1 >= ax2) or + (by1 >= ay2)) + def transformed(self, transform): """ Return a new Bbox object, transformed by the given transform. @@ -324,8 +332,139 @@ given transform. """ return Bbox(transform.inverted().transform(self.get_points())) - - + + coefs = {'C': (0.5, 0.5), + 'SW': (0,0), + 'S': (0.5, 0), + 'SE': (1.0, 0), + 'E': (1.0, 0.5), + 'NE': (1.0, 1.0), + 'N': (0.5, 1.0), + 'NW': (0, 1.0), + 'W': (0, 0.5)} + def anchored(self, c, container = None): + """ + Return a copy of the Bbox, shifted to position c within a + container. + + c: may be either a) a sequence (cx, cy) where cx, cy range + from 0 to 1, where 0 is left or bottom and 1 is right or top; + or b) a string: C for centered, S for bottom-center, SE for + bottom-left, E for left, etc. + + Optional arg container is the lbwh box within which the BBox + is positioned; it defaults to the initial BBox. + """ + if container is None: + container = self + l, b, w, h = container.bounds + if isinstance(c, str): + cx, cy = self.coefs[c] + else: + cx, cy = c + L, B, W, H = self.bounds + return Bbox(self._points + + [(l + cx * (w-W)) - L, + (b + cy * (h-H)) - B]) + + def shrunk(self, mx, my): + """ + Return a copy of the Bbox, shurnk by the factor mx in the x + direction and the factor my in the y direction. The lower + left corner of the box remains unchanged. Normally mx and my + will be <= 1, but this is not enforced. + """ + w, h = self.size + return Bbox([self._points[0], + self._points[0] + [mx * w, my * h]]) + + def shrunk_to_aspect(self, box_aspect, container = None, fig_aspect = 1.0): + """ + Return a copy of the Bbox, shrunk so that it is as large as it + can be while having the desired aspect ratio, box_aspect. If + the box coordinates are relative--that is, fractions of a + larger box such as a figure--then the physical aspect ratio of + that figure is specified with fig_aspect, so that box_aspect + can also be given as a ratio of the absolute dimensions, not + the relative dimensions. + """ + assert box_aspect > 0 and fig_aspect > 0 + if container is None: + container = self + w, h = container.size + H = w * box_aspect/fig_aspect + if H <= h: + W = w + else: + W = h * fig_aspect/box_aspect + H = h + return Bbox([self._points[0], + self._points[0] + (W, H)]) + + def splitx(self, *args): + ''' + e.g., bbox.splitx(f1, f2, ...) + + Returns a list of new BBoxes formed by + splitting the original one with vertical lines + at fractional positions f1, f2, ... + ''' + boxes = [] + xf = [0] + list(args) + [1] + l, b, r, t = self.lbrt + w = r - l + for xf0, xf1 in zip(xf[:-1], xf[1:]): + boxes.append(Bbox([[l + xf0 * w, b], [l + xf1 * w, t]])) + return boxes + + def splity(self, *args): + ''' + e.g., bbox.splitx(f1, f2, ...) + + Returns a list of new PBoxes formed by + splitting the original one with horizontal lines + at fractional positions f1, f2, ... + ''' + boxes = [] + yf = [0] + list(args) + [1] + l, b, r, t = self.lbrt + h = t - b + for yf0, yf1 in zip(yf[:-1], yf[1:]): + boxes.append(Bbox([[l, b + yf0 * h], [r, b + yf1 * h]])) + return boxes + + def count_contains(self, vertices): + if len(vertices) == 0: + return 0 + vertices = npy.asarray(vertices) + xmin, ymin, xmax, ymax = self._get_lbrt() + dxmin = npy.sign(vertices[:, 0] - xmin) + dymin = npy.sign(vertices[:, 1] - ymin) + dxmax = npy.sign(vertices[:, 0] - xmax) + dymax = npy.sign(vertices[:, 1] - ymax) + inside = (abs(dxmin + dxmax) + abs(dymin + dymax)) <= 2 + return N.sum(inside) + + def count_overlaps(self, bboxes): + ax1, ay1, ax2, ay2 = self._get_lbrt() + if ax2 < ax1: + ax2, ax1 = ax1, ax2 + if ay2 < ay1: + ay2, ay1 = ay1, ay2 + + count = 0 + for bbox in bboxes: + bx1, by1, bx2, by2 = bbox._get_lbrt() + if bx2 < bx1: + bx2, bx1 = bx1, bx2 + if by2 < by1: + by2, by1 = by1, by2 + count += (not ((bx2 <= ax1) or + (by2 <= ay1) or + (bx1 >= ax2) or + (by1 >= ay2))) + return count + class Bbox(BboxBase): def __init__(self, points): """ @@ -402,7 +541,7 @@ if len(x) == 0 or len(y) == 0: return - + if ma.isMaskedArray(x) or ma.isMaskedArray(y): xpos = ma.where(x > 0.0, x, npy.inf) ypos = ma.where(y > 0.0, y, npy.inf) @@ -430,6 +569,7 @@ max(y.max(), self.ymax)]], npy.float_) self._minpos = npy.minimum(minpos, self._minpos) + self.invalidate() def update_from_data_xy(self, xy, ignore=None): @@ -544,74 +684,6 @@ """ return Bbox(self._points + (tx, ty)) - coefs = {'C': (0.5, 0.5), - 'SW': (0,0), - 'S': (0.5, 0), - 'SE': (1.0, 0), - 'E': (1.0, 0.5), - 'NE': (1.0, 1.0), - 'N': (0.5, 1.0), - 'NW': (0, 1.0), - 'W': (0, 0.5)} - def anchored(self, c, container = None): - """ - Return a copy of the Bbox, shifted to position c within a - container. - - c: may be either a) a sequence (cx, cy) where cx, cy range - from 0 to 1, where 0 is left or bottom and 1 is right or top; - or b) a string: C for centered, S for bottom-center, SE for - bottom-left, E for left, etc. - - Optional arg container is the lbwh box within which the BBox - is positioned; it defaults to the initial BBox. - """ - if container is None: - container = self - l, b, w, h = container.bounds - if isinstance(c, str): - cx, cy = self.coefs[c] - else: - cx, cy = c - L, B, W, H = self.bounds - return Bbox(self._points + - [(l + cx * (w-W)) - L, - (b + cy * (h-H)) - B]) - - def shrunk(self, mx, my): - """ - Return a copy of the Bbox, shurnk by the factor mx in the x - direction and the factor my in the y direction. The lower - left corner of the box remains unchanged. Normally mx and my - will be <= 1, but this is not enforced. - """ - w, h = self.size - return Bbox([self._points[0], - self._points[1] - [w - (mx * w), h - (my * h)]]) - - def shrunk_to_aspect(self, box_aspect, container = None, fig_aspect = 1.0): - """ - Return a copy of the Bbox, shrunk so that it is as large as it - can be while having the desired aspect ratio, box_aspect. If - the box coordinates are relative--that is, fractions of a - larger box such as a figure--then the physical aspect ratio of - that figure is specified with fig_aspect, so that box_aspect - can also be given as a ratio of the absolute dimensions, not - the relative dimensions. - """ - assert box_aspect > 0 and fig_aspect > 0 - if container is None: - container = self - w, h = container.size - H = w * box_aspect/fig_aspect - if H <= h: - W = w - else: - W = h * fig_aspect/box_aspect - H = h - return Bbox([self._points[0], - self._points[0] + (W, H)]) - [EMAIL PROTECTED] def union(bboxes): """ @@ -1444,6 +1516,7 @@ return mtx[0, 1] == 0.0 and mtx[1, 0] == 0.0 is_separable = property(_get_is_separable) + class IdentityTransform(Affine2DBase): """ A special class that does on thing, the identity transform, in a @@ -1478,10 +1551,10 @@ transform_path.__doc__ = Affine2DBase.transform_path.__doc__ transform_path_affine = transform_path - transform_path_affine = Affine2DBase.transform_path_affine.__doc__ + transform_path_affine.__doc__ = Affine2DBase.transform_path_affine.__doc__ transform_path_non_affine = transform_path - transform_path_non_affine = Affine2DBase.transform_path_non_affine.__doc__ + transform_path_non_affine.__doc__ = Affine2DBase.transform_path_non_affine.__doc__ def get_affine(self): return self Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/src/_backend_agg.cpp 2007-10-11 15:42:53 UTC (rev 3934) @@ -605,8 +605,6 @@ agg::serialized_scanlines_adaptor_aa8::embedded_scanline sl; while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) { - x += 0.5; - y += 0.5; //render the fill if (face.first) { if (has_clippath) { @@ -948,8 +946,8 @@ Py::SeqBase<Py::Object> transforms_obj = args[5]; Py::Object offsets_obj = args[6]; agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[7], false); - Py::SeqBase<Py::Object> facecolors_obj = args[8]; - Py::SeqBase<Py::Object> edgecolors_obj = args[9]; + Py::Object facecolors_obj = args[8]; + Py::Object edgecolors_obj = args[9]; Py::SeqBase<Py::Float> linewidths = args[10]; Py::SeqBase<Py::Object> linestyles_obj = args[11]; Py::SeqBase<Py::Int> antialiaseds = args[12]; @@ -960,16 +958,31 @@ if (!offsets || offsets->dimensions[1] != 2) throw Py::ValueError("Offsets array must be Nx2"); + PyArrayObject* facecolors = (PyArrayObject*)PyArray_FromObject(facecolors_obj.ptr(), PyArray_DOUBLE, 1, 2); + if (!facecolors || + (facecolors->nd == 1 && facecolors->dimensions[0] != 0) || + (facecolors->nd == 2 && facecolors->dimensions[1] != 4)) + throw Py::ValueError("Facecolors must be a Nx4 numpy array or empty"); + + PyArrayObject* edgecolors = (PyArrayObject*)PyArray_FromObject(edgecolors_obj.ptr(), PyArray_DOUBLE, 1, 2); + if (!edgecolors || + (edgecolors->nd == 1 && edgecolors->dimensions[0] != 0) || + (edgecolors->nd == 2 && edgecolors->dimensions[1] != 4)) + throw Py::ValueError("Edgecolors must be a Nx4 numpy array"); + size_t Npaths = paths.length(); size_t Noffsets = offsets->dimensions[0]; size_t N = std::max(Npaths, Noffsets); size_t Ntransforms = std::min(transforms_obj.length(), N); - size_t Nfacecolors = std::min(facecolors_obj.length(), N); - size_t Nedgecolors = std::min(edgecolors_obj.length(), N); + size_t Nfacecolors = facecolors->dimensions[0]; + size_t Nedgecolors = edgecolors->dimensions[0]; size_t Nlinewidths = linewidths.length(); size_t Nlinestyles = std::min(linestyles_obj.length(), N); size_t Naa = antialiaseds.length(); + if ((Nfacecolors == 0 && Nedgecolors == 0) || N == 0) + return Py::Object(); + size_t i = 0; // Convert all of the transforms up front @@ -983,46 +996,6 @@ transforms.push_back(trans); } - // Convert all of the facecolors up front - typedef std::vector<facepair_t> facecolors_t; - facecolors_t facecolors; - facecolors.resize(Nfacecolors); - i = 0; - for (facecolors_t::iterator f = facecolors.begin(); - f != facecolors.end(); ++f, ++i) { - double r, g, b, a; - const Py::Object& facecolor_obj = facecolors_obj[i]; - if (facecolor_obj.ptr() == Py_None) - f->first = false; - else { - Py::SeqBase<Py::Float> facergba = facecolor_obj; - r = Py::Float(facergba[0]); - g = Py::Float(facergba[1]); - b = Py::Float(facergba[2]); - a = 1.0; - if (facergba.size() == 4) - a = Py::Float(facergba[3]); - f->first = true; - f->second = agg::rgba(r, g, b, a); - } - } - - // Convert all of the edgecolors up front - typedef std::vector<agg::rgba> edgecolors_t; - edgecolors_t edgecolors; - edgecolors.reserve(Nedgecolors); - for (i = 0; i < Nedgecolors; ++i) { - double r, g, b, a; - Py::SeqBase<Py::Float> edgergba(edgecolors_obj[i]); - r = Py::Float(edgergba[0]); - g = Py::Float(edgergba[1]); - b = Py::Float(edgergba[2]); - a = 1.0; - if (edgergba.size() == 4) - a = Py::Float(edgergba[3]); - edgecolors.push_back(agg::rgba(r, g, b, a)); - } - // Convert all the dashes up front typedef std::vector<std::pair<double, GCAgg::dash_t> > dashes_t; dashes_t dashes; @@ -1039,6 +1012,11 @@ set_clipbox(cliprect, theRasterizer); bool has_clippath = render_clippath(clippath, clippath_trans); + // Set some defaults, assuming no face or edge + gc.linewidth = 0.0; + facepair_t face; + face.first = Nfacecolors != 0; + for (i = 0; i < N; ++i) { PathIterator path(paths[i % Npaths]); bool snap = (path.total_vertices() == 2); @@ -1047,11 +1025,26 @@ offset_trans.transform(&xo, &yo); agg::trans_affine_translation transOffset(xo, yo); agg::trans_affine& trans = transforms[i % Ntransforms]; - facepair_t& face = facecolors[i % Nfacecolors]; - gc.color = edgecolors[i % Nedgecolors]; - gc.linewidth = double(Py::Float(linewidths[i % Nlinewidths])) * dpi/72.0; - gc.dashes = dashes[i % Nlinestyles].second; - gc.dashOffset = dashes[i % Nlinestyles].first; + + if (Nfacecolors) { + size_t fi = i % Nfacecolors; + face.second = agg::rgba(*(double*)PyArray_GETPTR2(facecolors, fi, 0), + *(double*)PyArray_GETPTR2(facecolors, fi, 1), + *(double*)PyArray_GETPTR2(facecolors, fi, 2), + *(double*)PyArray_GETPTR2(facecolors, fi, 3)); + } + + if (Nedgecolors) { + size_t ei = i % Nedgecolors; + gc.color = agg::rgba(*(double*)PyArray_GETPTR2(edgecolors, ei, 0), + *(double*)PyArray_GETPTR2(edgecolors, ei, 1), + *(double*)PyArray_GETPTR2(edgecolors, ei, 2), + *(double*)PyArray_GETPTR2(edgecolors, ei, 3)); + gc.linewidth = double(Py::Float(linewidths[i % Nlinewidths])) * dpi/72.0; + gc.dashes = dashes[i % Nlinestyles].second; + gc.dashOffset = dashes[i % Nlinestyles].first; + } + gc.isaa = bool(Py::Int(antialiaseds[i % Naa])); _draw_path(path, trans * transOffset, snap, has_clippath, face, gc); } @@ -1400,16 +1393,17 @@ template<class T> bool point_in_path_impl(double tx, double ty, T& path) { int yflag0, yflag1, inside_flag; - double vtx0, vty0, vtx1, vty1; + double vtx0, vty0, vtx1, vty1, sx, sy; double x, y; path.rewind(0); - if (path.vertex(&x, &y) == agg::path_cmd_stop) + unsigned code = path.vertex(&x, &y); + if (code == agg::path_cmd_stop) return false; while (true) { - vtx0 = x; - vty0 = y; + sx = vtx0 = x; + sy = vty0 = y; // get test bit for above/below X axis yflag0 = (vty0 >= ty); @@ -1419,14 +1413,13 @@ inside_flag = 0; while (true) { - unsigned code = path.vertex(&x, &y); - if (code == agg::path_cmd_stop) - return false; + code = path.vertex(&x, &y); + // The following cases denote the beginning on a new subpath - if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) + if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) { + x = sx; y = sy; + } else if (code == agg::path_cmd_move_to) break; - if (code == agg::path_cmd_move_to) - break; yflag1 = (vty1 >= ty); // Check if endpoints straddle (are on opposite sides) of X axis @@ -1459,10 +1452,17 @@ vtx1 = x; vty1 = y; + + if (code == agg::path_cmd_stop || + (code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) + break; } if (inside_flag != 0) return true; + + if (code == agg::path_cmd_stop) + return false; } return false; @@ -1641,15 +1641,18 @@ agg::trans_affine master_transform = py_to_agg_transformation_matrix(args[3]); Py::SeqBase<Py::Object> paths = args[4]; Py::SeqBase<Py::Object> transforms_obj = args[5]; - Py::SeqBase<Py::Object> offsets = args[6]; - agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[7], false); - Py::SeqBase<Py::Object> facecolors = args[8]; + Py::SeqBase<Py::Object> offsets_obj = args[6]; + agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[7]); + bool filled = Py::Int(args[8]); + PyArrayObject* offsets = (PyArrayObject*)PyArray_FromObject(offsets_obj.ptr(), PyArray_DOUBLE, 2, 2); + if (!offsets || offsets->dimensions[1] != 2) + throw Py::ValueError("Offsets array must be Nx2"); + size_t Npaths = paths.length(); - size_t Noffsets = offsets.length(); + size_t Noffsets = offsets->dimensions[0]; size_t N = std::max(Npaths, Noffsets); size_t Ntransforms = std::min(transforms_obj.length(), N); - size_t Ncolors = facecolors.length(); size_t i; // Convert all of the transforms up front @@ -1668,19 +1671,18 @@ for (i = 0; i < N; ++i) { PathIterator path(paths[i % Npaths]); - Py::SeqBase<Py::Float> offset = Py::SeqBase<Py::Float>(offsets[i % Noffsets]); - double xo = Py::Float(offset[0]); - double yo = Py::Float(offset[1]); + double xo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 0); + double yo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 1); offset_trans.transform(&xo, &yo); agg::trans_affine_translation transOffset(xo, yo); - agg::trans_affine trans = transforms[i % Ntransforms] * transOffset; + agg::trans_affine trans = transforms[i % Ntransforms]; + trans *= transOffset; - const Py::Object& facecolor_obj = facecolors[i & Ncolors]; - if (facecolor_obj.ptr() == Py_None) { - if (::point_on_path(x, y, radius, path, trans)) + if (filled) { + if (::point_in_path(x, y, path, trans)) result.append(Py::Int((int)i)); } else { - if (::point_in_path(x, y, path, trans)) + if (::point_on_path(x, y, radius, path, trans)) result.append(Py::Int((int)i)); } } Modified: branches/transforms/src/_backend_agg.h =================================================================== --- branches/transforms/src/_backend_agg.h 2007-10-10 13:38:32 UTC (rev 3933) +++ branches/transforms/src/_backend_agg.h 2007-10-11 15:42:53 UTC (rev 3934) @@ -247,7 +247,7 @@ add_varargs_method("get_path_collection_extents", &_backend_agg_module::get_path_collection_extents, "get_path_collection_extents(trans, paths, transforms, offsets, offsetTrans)"); add_varargs_method("point_in_path_collection", &_backend_agg_module::point_in_path_collection, - "point_in_path_collection(x, y, r, trans, paths, transforms, offsets, offsetTrans, colors)"); + "point_in_path_collection(x, y, r, trans, paths, transforms, offsets, offsetTrans, filled)"); initialize( "The agg rendering backend" ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins