Ryan May wrote: > On Fri, Apr 2, 2010 at 1:23 AM, Eric Firing <efir...@hawaii.edu> wrote: >>> On Fri, Mar 26, 2010 at 12:13 PM, Ryan May <rma...@gmail.com> wrote: >>>> I just hit a problem with using quiver with Basemap when when >>>> angles='xy'. Because Basemap's x,y units are in meters, you end up >>>> with angles that are quantized due to floating point truncation >>>> (30000. + 0.001*u = 30000.). Changing to angles='uv' fixes the >>>> problem, but it probably should be automatically scaled, as noted in >>>> the comments: >>>> >>>> elif self.angles == 'xy' or self.scale_units == 'xy': >>>> # We could refine this by calculating eps based on >>>> # the magnitude of U, V relative to that of X, Y, >>>> # to ensure we are always making small shifts in X, Y. >>>> >>>> I managed to fix the problem locally by setting: >>>> >>>> angles, lengths = self._angles_lengths(U, V, eps=0.0001 * >>>> self.XY.max()) >>>> >> I don't think this will work in all cases. For example, there could be a >> single arrow at (0,0). > > Good point. > >> Instead of self.XY.max(), how about abs(self.ax.dataLim.width)? > > Wouldn't this have problems if we zoom in sufficiently that the width > is much less than magnitude of the values? Not exactly sure what data > set would sensibly yield this, so I'm not sure if we should worry > about it. > > If we do care, we could just put a minimum bound on eps: > > eps=max(1e-8, 0.0001 * self.XY.max())
I don't like taking the max of a potentially large array every time; and one needs max absolute value in any case. I think the following is better: eps = np.abs(self.ax.dataLim.extents).max() * 0.001 Eric > > Ryan > ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel