[Yt-svn] commit/yt: JC Passy: Args *scale* and *scale_units* added to the VelocityCallback
Bitbucket
commits-noreply at bitbucket.org
Tue Jul 26 05:14:14 PDT 2011
1 new changeset in yt:
http://bitbucket.org/yt_analysis/yt/changeset/413592eb954c/
changeset: 413592eb954c
branch: yt
user: JC Passy
date: 2011-07-26 05:45:45
summary: Args *scale* and *scale_units* added to the VelocityCallback
affected #: 1 file (526 bytes)
--- a/yt/visualization/plot_modifications.py Mon Jul 25 14:48:26 2011 -0400
+++ b/yt/visualization/plot_modifications.py Mon Jul 25 20:45:45 2011 -0700
@@ -60,13 +60,17 @@
class VelocityCallback(PlotCallback):
_type_name = "velocity"
- def __init__(self, factor=16):
+ def __init__(self, factor=16, scale=None, scale_units=None):
"""
Adds a 'quiver' plot of velocity to the plot, skipping all but
every *factor* datapoint
+ *scale* is the data units per arrow length unit using *scale_units*
+ (see matplotlib.axes.Axes.quiver for more info)
"""
PlotCallback.__init__(self)
self.factor = factor
+ self.scale = scale
+ self.scale_units = scale_units
def __call__(self, plot):
# Instantiation of these is cheap
@@ -77,7 +81,7 @@
else:
xv = "%s-velocity" % (x_names[plot.data.axis])
yv = "%s-velocity" % (y_names[plot.data.axis])
- qcb = QuiverCallback(xv, yv, self.factor)
+ qcb = QuiverCallback(xv, yv, self.factor, self.scale, self.scale_units)
return qcb(plot)
class MagFieldCallback(PlotCallback):
@@ -102,16 +106,20 @@
class QuiverCallback(PlotCallback):
_type_name = "quiver"
- def __init__(self, field_x, field_y, factor):
+ def __init__(self, field_x, field_y, factor, scale, scale_units):
"""
Adds a 'quiver' plot to any plot, using the *field_x* and *field_y*
- from the associated data, skipping every *factor* datapoints.
+ from the associated data, skipping every *factor* datapoints
+ *scale* is the data units per arrow length unit using *scale_units*
+ (see matplotlib.axes.Axes.quiver for more info)
"""
PlotCallback.__init__(self)
self.field_x = field_x
self.field_y = field_y
self.bv_x = self.bv_y = 0
self.factor = factor
+ self.scale = scale
+ self.scale_units = scale_units
def __call__(self, plot):
x0, x1 = plot.xlim
@@ -137,7 +145,7 @@
(x0, x1, y0, y1),).transpose()
X = na.mgrid[0:plot.image._A.shape[0]-1:nx*1j]# + 0.5*factor
Y = na.mgrid[0:plot.image._A.shape[1]-1:ny*1j]# + 0.5*factor
- plot._axes.quiver(X,Y, pixX, pixY)
+ plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale, scale_units=self.scale_units)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
plot._axes.hold(False)
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list