[yt-svn] commit/yt: 7 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Dec 8 10:29:01 PST 2017
7 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/162c5d17d7b2/
Changeset: 162c5d17d7b2
User: jzuhone
Date: 2017-11-20 11:59:08+00:00
Summary: First pass at incorporating changing quiver color
Affected #: 1 file
diff -r 0e28d5ea5938979f536edf8f55dbc078f3406102 -r 162c5d17d7b2427034f003898f4a26914546aace yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -290,12 +290,14 @@
"""
_type_name = "velocity"
_supported_geometries = ("cartesian", "spectral_cube")
- def __init__(self, factor=16, scale=None, scale_units=None, normalize=False):
+ def __init__(self, factor=16, scale=None, scale_units=None,
+ normalize=False, color=None):
PlotCallback.__init__(self)
self.factor = factor
self.scale = scale
self.scale_units = scale_units
self.normalize = normalize
+ self.color = color
def __call__(self, plot):
# Instantiation of these is cheap
@@ -304,7 +306,8 @@
"cutting_plane_velocity_y",
self.factor, scale=self.scale,
normalize=self.normalize,
- scale_units=self.scale_units)
+ scale_units=self.scale_units,
+ color=self.color)
else:
ax = plot.data.axis
(xi, yi) = (plot.data.ds.coordinates.x_axis[ax],
@@ -321,7 +324,8 @@
qcb = QuiverCallback(xv, yv, self.factor, scale=self.scale,
scale_units=self.scale_units,
- normalize=self.normalize, bv_x=bv_x, bv_y=bv_y)
+ normalize=self.normalize, bv_x=bv_x,
+ bv_y=bv_y, color=self.color)
return qcb(plot)
class MagFieldCallback(PlotCallback):
@@ -336,12 +340,14 @@
"""
_type_name = "magnetic_field"
_supported_geometries = ("cartesian", "spectral_cube", "cylindrical-2d")
- def __init__(self, factor=16, scale=None, scale_units=None, normalize=False):
+ def __init__(self, factor=16, scale=None, scale_units=None,
+ normalize=False, color=None):
PlotCallback.__init__(self)
self.factor = factor
self.scale = scale
self.scale_units = scale_units
self.normalize = normalize
+ self.color = color
def __call__(self, plot):
# Instantiation of these is cheap
@@ -350,14 +356,17 @@
"cutting_plane_magnetic_field_y",
self.factor, scale=self.scale,
scale_units=self.scale_units,
- normalize=self.normalize)
+ normalize=self.normalize,
+ color=self.color)
else:
xax = plot.data.ds.coordinates.x_axis[plot.data.axis]
yax = plot.data.ds.coordinates.y_axis[plot.data.axis]
axis_names = plot.data.ds.coordinates.axis_name
xv = "magnetic_field_%s" % (axis_names[xax])
yv = "magnetic_field_%s" % (axis_names[yax])
- qcb = QuiverCallback(xv, yv, self.factor, scale=self.scale, scale_units=self.scale_units, normalize=self.normalize)
+ qcb = QuiverCallback(xv, yv, self.factor, scale=self.scale,
+ scale_units=self.scale_units,
+ normalize=self.normalize, color=self.color)
return qcb(plot)
class QuiverCallback(PlotCallback):
@@ -370,7 +379,8 @@
_type_name = "quiver"
_supported_geometries = ("cartesian", "spectral_cube", "cylindrical-2d")
def __init__(self, field_x, field_y, factor=16, scale=None,
- scale_units=None, normalize=False, bv_x=0, bv_y=0):
+ scale_units=None, color=None, normalize=False,
+ bv_x=0, bv_y=0):
PlotCallback.__init__(self)
self.field_x = field_x
self.field_y = field_y
@@ -380,6 +390,7 @@
self.scale = scale
self.scale_units = scale_units
self.normalize = normalize
+ self.color = color
def __call__(self, plot):
x0, x1 = [p.to('code_length') for p in plot.xlim]
@@ -424,7 +435,8 @@
nn = np.sqrt(pixX**2 + pixY**2)
pixX /= nn
pixY /= nn
- plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale, scale_units=self.scale_units)
+ plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale,
+ color=self.color, scale_units=self.scale_units)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
@@ -833,7 +845,7 @@
_supported_geometries = ("cartesian", "spectral_cube")
def __init__(self, field_x, field_y, factor=16, scale=None,
- scale_units=None, normalize=None):
+ scale_units=None, normalize=None, color=None):
PlotCallback.__init__(self)
self.field_x = field_x
self.field_y = field_y
@@ -841,6 +853,7 @@
self.scale = scale
self.scale_units = scale_units
self.normalize = normalize
+ self.color = color
def __call__(self, plot):
x0, x1 = [p.to('code_length') for p in plot.xlim]
@@ -875,7 +888,8 @@
pixX /= nn
pixY /= nn
- plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale, scale_units=self.scale_units)
+ plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale,
+ scale_units=self.scale_units, color=self.color)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
https://bitbucket.org/yt_analysis/yt/commits/c0e9faf143ea/
Changeset: c0e9faf143ea
User: jzuhone
Date: 2017-11-20 12:05:21+00:00
Summary: Default color should be black
Affected #: 1 file
diff -r 162c5d17d7b2427034f003898f4a26914546aace -r c0e9faf143ea11011440c4665cb1b900079cef60 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -291,7 +291,7 @@
_type_name = "velocity"
_supported_geometries = ("cartesian", "spectral_cube")
def __init__(self, factor=16, scale=None, scale_units=None,
- normalize=False, color=None):
+ normalize=False, color="k"):
PlotCallback.__init__(self)
self.factor = factor
self.scale = scale
@@ -341,7 +341,7 @@
_type_name = "magnetic_field"
_supported_geometries = ("cartesian", "spectral_cube", "cylindrical-2d")
def __init__(self, factor=16, scale=None, scale_units=None,
- normalize=False, color=None):
+ normalize=False, color="k"):
PlotCallback.__init__(self)
self.factor = factor
self.scale = scale
@@ -379,7 +379,7 @@
_type_name = "quiver"
_supported_geometries = ("cartesian", "spectral_cube", "cylindrical-2d")
def __init__(self, field_x, field_y, factor=16, scale=None,
- scale_units=None, color=None, normalize=False,
+ scale_units=None, color="k", normalize=False,
bv_x=0, bv_y=0):
PlotCallback.__init__(self)
self.field_x = field_x
@@ -845,7 +845,7 @@
_supported_geometries = ("cartesian", "spectral_cube")
def __init__(self, field_x, field_y, factor=16, scale=None,
- scale_units=None, normalize=None, color=None):
+ scale_units=None, normalize=None, color="k"):
PlotCallback.__init__(self)
self.field_x = field_x
self.field_y = field_y
https://bitbucket.org/yt_analysis/yt/commits/8408489b488b/
Changeset: 8408489b488b
User: jzuhone
Date: 2017-11-21 08:22:38+00:00
Summary: Updated docstrings
Affected #: 1 file
diff -r c0e9faf143ea11011440c4665cb1b900079cef60 -r 8408489b488b7e3dd12637ee3c8e10b732f96012 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -281,7 +281,7 @@
"""
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
+ length unit using *scale_units* and *color* sets the color (see
matplotlib.axes.Axes.quiver for more info). if *normalize* is
True, the velocity fields will be scaled by their local
(in-plane) length, allowing morphological features to be more
@@ -332,9 +332,9 @@
"""
Adds a 'quiver' plot of magnetic field 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). if *normalize* is
- True, the magnetic fields will be scaled by their local
+ length unit using *scale_units* and *color* sets the color of the
+ arrows (see matplotlib.axes.Axes.quiver for more info). if
+ *normalize* is True, the magnetic fields will be scaled by their local
(in-plane) length, allowing morphological features to be more
clearly seen for fields with substantial variation in field strength.
"""
@@ -372,9 +372,12 @@
class QuiverCallback(PlotCallback):
"""
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)
+ and *color* sets the color of the arrows (see matplotlib.axes.Axes.quiver
+ for more info). if *normalize* is True, the fields will be scaled by
+ their local (in-plane) length, allowing morphological features to be more
+ clearly seen for fields with substantial variation in field strength.
"""
_type_name = "quiver"
_supported_geometries = ("cartesian", "spectral_cube", "cylindrical-2d")
@@ -840,6 +843,11 @@
"""
Get a quiver plot on top of a cutting plane, using *field_x* and
*field_y*, skipping every *factor* datapoint in the discretization.
+ *scale* is the data units per arrow length unit using *scale_units*
+ and *color* sets the color of the arrows (see matplotlib.axes.Axes.quiver
+ for more info). if *normalize* is True, the fields will be scaled by
+ their local (in-plane) length, allowing morphological features to be more
+ clearly seen for fields with substantial variation in field strength.
"""
_type_name = "cquiver"
_supported_geometries = ("cartesian", "spectral_cube")
https://bitbucket.org/yt_analysis/yt/commits/187ab0478e72/
Changeset: 187ab0478e72
User: jzuhone
Date: 2017-11-29 19:01:59+00:00
Summary: Allow generic matplotlib arguments to be passed in
Affected #: 1 file
diff -r 8408489b488b7e3dd12637ee3c8e10b732f96012 -r 187ab0478e727bc2ad465160a66b9fbbbc3f1432 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -281,23 +281,25 @@
"""
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* and *color* sets the color (see
- matplotlib.axes.Axes.quiver for more info). if *normalize* is
- True, the velocity fields will be scaled by their local
- (in-plane) length, allowing morphological features to be more
- clearly seen for fields with substantial variation in field
- strength.
+ length unit using *scale_units* and *plot_args* allows you to
+ pass in matplotlib arguments (see matplotlib.axes.Axes.quiver
+ for more info). if *normalize* is True, the velocity fields
+ will be scaled by their local (in-plane) length, allowing
+ morphological features to be more clearly seen for fields
+ with substantial variation in field strength.
"""
_type_name = "velocity"
_supported_geometries = ("cartesian", "spectral_cube")
def __init__(self, factor=16, scale=None, scale_units=None,
- normalize=False, color="k"):
+ normalize=False, plot_args=None):
PlotCallback.__init__(self)
self.factor = factor
self.scale = scale
self.scale_units = scale_units
self.normalize = normalize
- self.color = color
+ if plot_args is None:
+ plot_args = {}
+ self.plot_args = plot_args
def __call__(self, plot):
# Instantiation of these is cheap
@@ -307,7 +309,7 @@
self.factor, scale=self.scale,
normalize=self.normalize,
scale_units=self.scale_units,
- color=self.color)
+ plot_args=self.plot_args)
else:
ax = plot.data.axis
(xi, yi) = (plot.data.ds.coordinates.x_axis[ax],
@@ -325,29 +327,31 @@
qcb = QuiverCallback(xv, yv, self.factor, scale=self.scale,
scale_units=self.scale_units,
normalize=self.normalize, bv_x=bv_x,
- bv_y=bv_y, color=self.color)
+ bv_y=bv_y, plot_args=self.plot_args)
return qcb(plot)
class MagFieldCallback(PlotCallback):
"""
Adds a 'quiver' plot of magnetic field to the plot, skipping all but
every *factor* datapoint. *scale* is the data units per arrow
- length unit using *scale_units* and *color* sets the color of the
- arrows (see matplotlib.axes.Axes.quiver for more info). if
- *normalize* is True, the magnetic fields will be scaled by their local
- (in-plane) length, allowing morphological features to be more
+ length unit using *scale_units* and *plot_args* allows you to pass
+ in matplotlib arguments (see matplotlib.axes.Axes.quiver for more info).
+ if *normalize* is True, the magnetic fields will be scaled by their
+ local (in-plane) length, allowing morphological features to be more
clearly seen for fields with substantial variation in field strength.
"""
_type_name = "magnetic_field"
_supported_geometries = ("cartesian", "spectral_cube", "cylindrical-2d")
def __init__(self, factor=16, scale=None, scale_units=None,
- normalize=False, color="k"):
+ normalize=False, plot_args=None):
PlotCallback.__init__(self)
self.factor = factor
self.scale = scale
self.scale_units = scale_units
self.normalize = normalize
- self.color = color
+ if plot_args is None:
+ plot_args = {}
+ self.plot_args = plot_args
def __call__(self, plot):
# Instantiation of these is cheap
@@ -357,7 +361,7 @@
self.factor, scale=self.scale,
scale_units=self.scale_units,
normalize=self.normalize,
- color=self.color)
+ plot_args=self.plot_args)
else:
xax = plot.data.ds.coordinates.x_axis[plot.data.axis]
yax = plot.data.ds.coordinates.y_axis[plot.data.axis]
@@ -365,8 +369,9 @@
xv = "magnetic_field_%s" % (axis_names[xax])
yv = "magnetic_field_%s" % (axis_names[yax])
qcb = QuiverCallback(xv, yv, self.factor, scale=self.scale,
- scale_units=self.scale_units,
- normalize=self.normalize, color=self.color)
+ scale_units=self.scale_units,
+ normalize=self.normalize,
+ plot_args=self.plot_args)
return qcb(plot)
class QuiverCallback(PlotCallback):
@@ -374,16 +379,17 @@
Adds a 'quiver' plot to any plot, using the *field_x* and *field_y*
from the associated data, skipping every *factor* datapoints.
*scale* is the data units per arrow length unit using *scale_units*
- and *color* sets the color of the arrows (see matplotlib.axes.Axes.quiver
- for more info). if *normalize* is True, the fields will be scaled by
- their local (in-plane) length, allowing morphological features to be more
- clearly seen for fields with substantial variation in field strength.
+ and *plot_args* allows you to pass in matplotlib arguments (see
+ matplotlib.axes.Axes.quiver for more info). if *normalize* is True,
+ the fields will be scaled by their local (in-plane) length, allowing
+ morphological features to be more clearly seen for fields with
+ substantial variation in field strength.
"""
_type_name = "quiver"
_supported_geometries = ("cartesian", "spectral_cube", "cylindrical-2d")
def __init__(self, field_x, field_y, factor=16, scale=None,
- scale_units=None, color="k", normalize=False,
- bv_x=0, bv_y=0):
+ scale_units=None, normalize=False, bv_x=0, bv_y=0,
+ plot_args=None):
PlotCallback.__init__(self)
self.field_x = field_x
self.field_y = field_y
@@ -393,7 +399,9 @@
self.scale = scale
self.scale_units = scale_units
self.normalize = normalize
- self.color = color
+ if plot_args is None:
+ plot_args = {}
+ self.plot_args = plot_args
def __call__(self, plot):
x0, x1 = [p.to('code_length') for p in plot.xlim]
@@ -439,7 +447,7 @@
pixX /= nn
pixY /= nn
plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale,
- color=self.color, scale_units=self.scale_units)
+ scale_units=self.scale_units, **self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
@@ -844,16 +852,17 @@
Get a quiver plot on top of a cutting plane, using *field_x* and
*field_y*, skipping every *factor* datapoint in the discretization.
*scale* is the data units per arrow length unit using *scale_units*
- and *color* sets the color of the arrows (see matplotlib.axes.Axes.quiver
- for more info). if *normalize* is True, the fields will be scaled by
- their local (in-plane) length, allowing morphological features to be more
- clearly seen for fields with substantial variation in field strength.
+ and *plot_args* allows you to pass in matplotlib arguments (see
+ matplotlib.axes.Axes.quiver for more info). if *normalize* is True,
+ the fields will be scaled by their local (in-plane) length, allowing
+ morphological features to be more clearly seen for fields with
+ substantial variation in field strength.
"""
_type_name = "cquiver"
_supported_geometries = ("cartesian", "spectral_cube")
def __init__(self, field_x, field_y, factor=16, scale=None,
- scale_units=None, normalize=None, color="k"):
+ scale_units=None, normalize=None, plot_args=None):
PlotCallback.__init__(self)
self.field_x = field_x
self.field_y = field_y
@@ -861,7 +870,9 @@
self.scale = scale
self.scale_units = scale_units
self.normalize = normalize
- self.color = color
+ if plot_args is None:
+ plot_args = {}
+ self.plot_args = plot_args
def __call__(self, plot):
x0, x1 = [p.to('code_length') for p in plot.xlim]
@@ -897,7 +908,7 @@
pixY /= nn
plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale,
- scale_units=self.scale_units, color=self.color)
+ scale_units=self.scale_units, **self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
https://bitbucket.org/yt_analysis/yt/commits/76122dd5b1aa/
Changeset: 76122dd5b1aa
User: jzuhone
Date: 2017-12-05 17:05:52+00:00
Summary: This should be False
Affected #: 1 file
diff -r 187ab0478e727bc2ad465160a66b9fbbbc3f1432 -r 76122dd5b1aa4eaf448c24bfc39af9225157bf72 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -862,7 +862,7 @@
_supported_geometries = ("cartesian", "spectral_cube")
def __init__(self, field_x, field_y, factor=16, scale=None,
- scale_units=None, normalize=None, plot_args=None):
+ scale_units=None, normalize=False, plot_args=None):
PlotCallback.__init__(self)
self.field_x = field_x
self.field_y = field_y
https://bitbucket.org/yt_analysis/yt/commits/78cf2f09c54a/
Changeset: 78cf2f09c54a
User: jzuhone
Date: 2017-12-05 17:16:21+00:00
Summary: Update documentation to include new options and make sure we show all arguments
Affected #: 1 file
diff -r 76122dd5b1aa4eaf448c24bfc39af9225157bf72 -r 78cf2f09c54ae3a1a27b12eb41266fd1737934c8 doc/source/visualizing/callbacks.rst
--- a/doc/source/visualizing/callbacks.rst
+++ b/doc/source/visualizing/callbacks.rst
@@ -208,16 +208,20 @@
Axis-Aligned Data Sources
^^^^^^^^^^^^^^^^^^^^^^^^^
-.. function:: annotate_quiver(self, field_x, field_y, factor, scale=None, \
- scale_units=None, normalize=False)
+.. function:: annotate_quiver(self, field_x, field_y, factor=16, scale=None, \
+ scale_units=None, normalize=False, plot_args=None)
(This is a proxy for
:class:`~yt.visualization.plot_modifications.QuiverCallback`.)
Adds a 'quiver' plot to any plot, using the ``field_x`` and ``field_y`` 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)
+ the associated data, skipping every ``factor`` datapoints in the
+ discretization. ``scale`` is the data units per arrow length unit using
+ ``scale_units``. If ``normalize`` is ``True``, the fields will be scaled by
+ their local (in-plane) length, allowing morphological features to be more
+ clearly seen for fields with substantial variation in field strength.
+ Additional arguments can be passed to the ``plot_args`` dictionary, see
+ matplotlib.axes.Axes.quiver for more info.
.. python-script::
@@ -225,26 +229,35 @@
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
p = yt.ProjectionPlot(ds, 'z', 'density', center=[0.5, 0.5, 0.5],
weight_field='density', width=(20, 'kpc'))
- p.annotate_quiver('velocity_x', 'velocity_y', 16)
+ p.annotate_quiver('velocity_x', 'velocity_y', factor=16,
+ plot_args={"color":"purple})
p.save()
Off-Axis Data Sources
^^^^^^^^^^^^^^^^^^^^^
-.. function:: annotate_cquiver(self, field_x, field_y, factor)
+.. function:: annotate_cquiver(self, field_x, field_y, factor=16, scale=None, \
+ scale_units=None, normalize=False, plot_args=None)
(This is a proxy for
:class:`~yt.visualization.plot_modifications.CuttingQuiverCallback`.)
- Get a quiver plot on top of a cutting plane, using ``field_x`` and
- ``field_y``, skipping every ``factor`` datapoint in the discretization.
+ Get a quiver plot on top of a cutting plane, using the ``field_x`` and
+ ``field_y`` from the associated data, skipping every ``factor`` datapoints in
+ the discretization. ``scale`` is the data units per arrow length unit using
+ ``scale_units``. If ``normalize`` is ``True``, the fields will be scaled by
+ their local (in-plane) length, allowing morphological features to be more
+ clearly seen for fields with substantial variation in field strength.
+ Additional arguments can be passed to the ``plot_args`` dictionary, see
+ matplotlib.axes.Axes.quiver for more info.
.. python-script::
import yt
ds = yt.load("Enzo_64/DD0043/data0043")
s = yt.OffAxisSlicePlot(ds, [1,1,0], ["density"], center="c")
- s.annotate_cquiver('cutting_plane_velocity_x', 'cutting_plane_velocity_y', 10)
+ s.annotate_cquiver('cutting_plane_velocity_x', 'cutting_plane_velocity_y',
+ factor=10, plot_args={'color':'orange'})
s.zoom(1.5)
s.save()
@@ -383,17 +396,19 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. function:: annotate_magnetic_field(self, factor=16, scale=None, \
- scale_units=None, normalize=False)
+ scale_units=None, normalize=False, \
+ plot_args=None)
(This is a proxy for
:class:`~yt.visualization.plot_modifications.MagFieldCallback`.)
- Adds a 'quiver' plot of magnetic field 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). if
- ``normalize`` is ``True``, the magnetic fields will be scaled by their local
- (in-plane) length, allowing morphological features to be more clearly seen
- for fields with substantial variation in field strength.
+ Adds a 'quiver' plot of magnetic field to the plot, skipping every ``factor``
+ datapoints in the discretization. ``scale`` is the data units per arrow
+ length unit using ``scale_units``. If ``normalize`` is ``True``, the
+ magnetic fields will be scaled by their local (in-plane) length, allowing
+ morphological features to be more clearly seen for fields with substantial
+ variation in field strength. Additional arguments can be passed to the
+ ``plot_args`` dictionary, see matplotlib.axes.Axes.quiver for more info.
.. python-script::
@@ -402,7 +417,7 @@
parameters={"time_unit":(1, 'Myr'), "length_unit":(1, 'Mpc'),
"mass_unit":(1e17, 'Msun')})
p = yt.ProjectionPlot(ds, 'z', 'density', center='c', width=(300, 'kpc'))
- p.annotate_magnetic_field()
+ p.annotate_magnetic_field(plot_args={"headlength": 3})
p.save()
.. _annotate-marker:
@@ -578,26 +593,26 @@
Overplot Quivers for the Velocity Field
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.. function:: annotate_velocity(self, factor=16, scale=None, scale_units=None,\
- normalize=False)
+.. function:: annotate_velocity(self, factor=16, scale=None, scale_units=None, \
+ normalize=False, plot_args=None)
(This is a proxy for
:class:`~yt.visualization.plot_modifications.VelocityCallback`.)
- 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). if
- ``normalize`` is ``True``, the velocity fields will be scaled by their local
- (in-plane) length, allowing morphological features to be more clearly seen
- for fields with substantial variation in field strength (normalize is not
- implemented and thus ignored for Cutting Planes).
+ Adds a 'quiver' plot of velocity to the plot, skipping every ``factor``
+ datapoints in the discretization. ``scale`` is the data units per arrow
+ length unit using ``scale_units``. If ``normalize`` is ``True``, the
+ velocity fields will be scaled by their local (in-plane) length, allowing
+ morphological features to be more clearly seen for fields with substantial
+ variation in field strength. Additional arguments can be passed to the
+ ``plot_args`` dictionary, see matplotlib.axes.Axes.quiver for more info.
.. python-script::
import yt
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
p = yt.SlicePlot(ds, 'z', 'density', center='m', width=(10, 'kpc'))
- p.annotate_velocity()
+ p.annotate_velocity(plot_args={"headwidth": 4})
p.save()
.. _annotate-timestamp:
https://bitbucket.org/yt_analysis/yt/commits/7731f952da66/
Changeset: 7731f952da66
User: ngoldbaum
Date: 2017-12-08 18:28:47+00:00
Summary: Merge pull request #1636 from jzuhone/quiver_color
Pass in matplotlib arguments to quiver annotations
Affected #: 2 files
diff -r 91ee6f6250a69efdb25302026b71d6c9df09ab9b -r 7731f952da66a137239a2a6a312997c404c2d58c doc/source/visualizing/callbacks.rst
--- a/doc/source/visualizing/callbacks.rst
+++ b/doc/source/visualizing/callbacks.rst
@@ -208,16 +208,20 @@
Axis-Aligned Data Sources
^^^^^^^^^^^^^^^^^^^^^^^^^
-.. function:: annotate_quiver(self, field_x, field_y, factor, scale=None, \
- scale_units=None, normalize=False)
+.. function:: annotate_quiver(self, field_x, field_y, factor=16, scale=None, \
+ scale_units=None, normalize=False, plot_args=None)
(This is a proxy for
:class:`~yt.visualization.plot_modifications.QuiverCallback`.)
Adds a 'quiver' plot to any plot, using the ``field_x`` and ``field_y`` 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)
+ the associated data, skipping every ``factor`` datapoints in the
+ discretization. ``scale`` is the data units per arrow length unit using
+ ``scale_units``. If ``normalize`` is ``True``, the fields will be scaled by
+ their local (in-plane) length, allowing morphological features to be more
+ clearly seen for fields with substantial variation in field strength.
+ Additional arguments can be passed to the ``plot_args`` dictionary, see
+ matplotlib.axes.Axes.quiver for more info.
.. python-script::
@@ -225,26 +229,35 @@
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
p = yt.ProjectionPlot(ds, 'z', 'density', center=[0.5, 0.5, 0.5],
weight_field='density', width=(20, 'kpc'))
- p.annotate_quiver('velocity_x', 'velocity_y', 16)
+ p.annotate_quiver('velocity_x', 'velocity_y', factor=16,
+ plot_args={"color":"purple})
p.save()
Off-Axis Data Sources
^^^^^^^^^^^^^^^^^^^^^
-.. function:: annotate_cquiver(self, field_x, field_y, factor)
+.. function:: annotate_cquiver(self, field_x, field_y, factor=16, scale=None, \
+ scale_units=None, normalize=False, plot_args=None)
(This is a proxy for
:class:`~yt.visualization.plot_modifications.CuttingQuiverCallback`.)
- Get a quiver plot on top of a cutting plane, using ``field_x`` and
- ``field_y``, skipping every ``factor`` datapoint in the discretization.
+ Get a quiver plot on top of a cutting plane, using the ``field_x`` and
+ ``field_y`` from the associated data, skipping every ``factor`` datapoints in
+ the discretization. ``scale`` is the data units per arrow length unit using
+ ``scale_units``. If ``normalize`` is ``True``, the fields will be scaled by
+ their local (in-plane) length, allowing morphological features to be more
+ clearly seen for fields with substantial variation in field strength.
+ Additional arguments can be passed to the ``plot_args`` dictionary, see
+ matplotlib.axes.Axes.quiver for more info.
.. python-script::
import yt
ds = yt.load("Enzo_64/DD0043/data0043")
s = yt.OffAxisSlicePlot(ds, [1,1,0], ["density"], center="c")
- s.annotate_cquiver('cutting_plane_velocity_x', 'cutting_plane_velocity_y', 10)
+ s.annotate_cquiver('cutting_plane_velocity_x', 'cutting_plane_velocity_y',
+ factor=10, plot_args={'color':'orange'})
s.zoom(1.5)
s.save()
@@ -383,17 +396,19 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. function:: annotate_magnetic_field(self, factor=16, scale=None, \
- scale_units=None, normalize=False)
+ scale_units=None, normalize=False, \
+ plot_args=None)
(This is a proxy for
:class:`~yt.visualization.plot_modifications.MagFieldCallback`.)
- Adds a 'quiver' plot of magnetic field 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). if
- ``normalize`` is ``True``, the magnetic fields will be scaled by their local
- (in-plane) length, allowing morphological features to be more clearly seen
- for fields with substantial variation in field strength.
+ Adds a 'quiver' plot of magnetic field to the plot, skipping every ``factor``
+ datapoints in the discretization. ``scale`` is the data units per arrow
+ length unit using ``scale_units``. If ``normalize`` is ``True``, the
+ magnetic fields will be scaled by their local (in-plane) length, allowing
+ morphological features to be more clearly seen for fields with substantial
+ variation in field strength. Additional arguments can be passed to the
+ ``plot_args`` dictionary, see matplotlib.axes.Axes.quiver for more info.
.. python-script::
@@ -402,7 +417,7 @@
parameters={"time_unit":(1, 'Myr'), "length_unit":(1, 'Mpc'),
"mass_unit":(1e17, 'Msun')})
p = yt.ProjectionPlot(ds, 'z', 'density', center='c', width=(300, 'kpc'))
- p.annotate_magnetic_field()
+ p.annotate_magnetic_field(plot_args={"headlength": 3})
p.save()
.. _annotate-marker:
@@ -578,26 +593,26 @@
Overplot Quivers for the Velocity Field
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.. function:: annotate_velocity(self, factor=16, scale=None, scale_units=None,\
- normalize=False)
+.. function:: annotate_velocity(self, factor=16, scale=None, scale_units=None, \
+ normalize=False, plot_args=None)
(This is a proxy for
:class:`~yt.visualization.plot_modifications.VelocityCallback`.)
- 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). if
- ``normalize`` is ``True``, the velocity fields will be scaled by their local
- (in-plane) length, allowing morphological features to be more clearly seen
- for fields with substantial variation in field strength (normalize is not
- implemented and thus ignored for Cutting Planes).
+ Adds a 'quiver' plot of velocity to the plot, skipping every ``factor``
+ datapoints in the discretization. ``scale`` is the data units per arrow
+ length unit using ``scale_units``. If ``normalize`` is ``True``, the
+ velocity fields will be scaled by their local (in-plane) length, allowing
+ morphological features to be more clearly seen for fields with substantial
+ variation in field strength. Additional arguments can be passed to the
+ ``plot_args`` dictionary, see matplotlib.axes.Axes.quiver for more info.
.. python-script::
import yt
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
p = yt.SlicePlot(ds, 'z', 'density', center='m', width=(10, 'kpc'))
- p.annotate_velocity()
+ p.annotate_velocity(plot_args={"headwidth": 4})
p.save()
.. _annotate-timestamp:
diff -r 91ee6f6250a69efdb25302026b71d6c9df09ab9b -r 7731f952da66a137239a2a6a312997c404c2d58c yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -281,21 +281,25 @@
"""
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). if *normalize* is
- True, the velocity fields will be scaled by their local
- (in-plane) length, allowing morphological features to be more
- clearly seen for fields with substantial variation in field
- strength.
+ length unit using *scale_units* and *plot_args* allows you to
+ pass in matplotlib arguments (see matplotlib.axes.Axes.quiver
+ for more info). if *normalize* is True, the velocity fields
+ will be scaled by their local (in-plane) length, allowing
+ morphological features to be more clearly seen for fields
+ with substantial variation in field strength.
"""
_type_name = "velocity"
_supported_geometries = ("cartesian", "spectral_cube")
- def __init__(self, factor=16, scale=None, scale_units=None, normalize=False):
+ def __init__(self, factor=16, scale=None, scale_units=None,
+ normalize=False, plot_args=None):
PlotCallback.__init__(self)
self.factor = factor
self.scale = scale
self.scale_units = scale_units
self.normalize = normalize
+ if plot_args is None:
+ plot_args = {}
+ self.plot_args = plot_args
def __call__(self, plot):
# Instantiation of these is cheap
@@ -304,7 +308,8 @@
"cutting_plane_velocity_y",
self.factor, scale=self.scale,
normalize=self.normalize,
- scale_units=self.scale_units)
+ scale_units=self.scale_units,
+ plot_args=self.plot_args)
else:
ax = plot.data.axis
(xi, yi) = (plot.data.ds.coordinates.x_axis[ax],
@@ -321,27 +326,32 @@
qcb = QuiverCallback(xv, yv, self.factor, scale=self.scale,
scale_units=self.scale_units,
- normalize=self.normalize, bv_x=bv_x, bv_y=bv_y)
+ normalize=self.normalize, bv_x=bv_x,
+ bv_y=bv_y, plot_args=self.plot_args)
return qcb(plot)
class MagFieldCallback(PlotCallback):
"""
Adds a 'quiver' plot of magnetic field 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). if *normalize* is
- True, the magnetic fields will be scaled by their local
- (in-plane) length, allowing morphological features to be more
+ length unit using *scale_units* and *plot_args* allows you to pass
+ in matplotlib arguments (see matplotlib.axes.Axes.quiver for more info).
+ if *normalize* is True, the magnetic fields will be scaled by their
+ local (in-plane) length, allowing morphological features to be more
clearly seen for fields with substantial variation in field strength.
"""
_type_name = "magnetic_field"
_supported_geometries = ("cartesian", "spectral_cube", "cylindrical-2d")
- def __init__(self, factor=16, scale=None, scale_units=None, normalize=False):
+ def __init__(self, factor=16, scale=None, scale_units=None,
+ normalize=False, plot_args=None):
PlotCallback.__init__(self)
self.factor = factor
self.scale = scale
self.scale_units = scale_units
self.normalize = normalize
+ if plot_args is None:
+ plot_args = {}
+ self.plot_args = plot_args
def __call__(self, plot):
# Instantiation of these is cheap
@@ -350,27 +360,36 @@
"cutting_plane_magnetic_field_y",
self.factor, scale=self.scale,
scale_units=self.scale_units,
- normalize=self.normalize)
+ normalize=self.normalize,
+ plot_args=self.plot_args)
else:
xax = plot.data.ds.coordinates.x_axis[plot.data.axis]
yax = plot.data.ds.coordinates.y_axis[plot.data.axis]
axis_names = plot.data.ds.coordinates.axis_name
xv = "magnetic_field_%s" % (axis_names[xax])
yv = "magnetic_field_%s" % (axis_names[yax])
- qcb = QuiverCallback(xv, yv, self.factor, scale=self.scale, scale_units=self.scale_units, normalize=self.normalize)
+ qcb = QuiverCallback(xv, yv, self.factor, scale=self.scale,
+ scale_units=self.scale_units,
+ normalize=self.normalize,
+ plot_args=self.plot_args)
return qcb(plot)
class QuiverCallback(PlotCallback):
"""
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)
+ and *plot_args* allows you to pass in matplotlib arguments (see
+ matplotlib.axes.Axes.quiver for more info). if *normalize* is True,
+ the fields will be scaled by their local (in-plane) length, allowing
+ morphological features to be more clearly seen for fields with
+ substantial variation in field strength.
"""
_type_name = "quiver"
_supported_geometries = ("cartesian", "spectral_cube", "cylindrical-2d")
def __init__(self, field_x, field_y, factor=16, scale=None,
- scale_units=None, normalize=False, bv_x=0, bv_y=0):
+ scale_units=None, normalize=False, bv_x=0, bv_y=0,
+ plot_args=None):
PlotCallback.__init__(self)
self.field_x = field_x
self.field_y = field_y
@@ -380,6 +399,9 @@
self.scale = scale
self.scale_units = scale_units
self.normalize = normalize
+ if plot_args is None:
+ plot_args = {}
+ self.plot_args = plot_args
def __call__(self, plot):
x0, x1 = [p.to('code_length') for p in plot.xlim]
@@ -424,7 +446,8 @@
nn = np.sqrt(pixX**2 + pixY**2)
pixX /= nn
pixY /= nn
- plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale, scale_units=self.scale_units)
+ plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale,
+ scale_units=self.scale_units, **self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
@@ -828,12 +851,18 @@
"""
Get a quiver plot on top of a cutting plane, using *field_x* and
*field_y*, skipping every *factor* datapoint in the discretization.
+ *scale* is the data units per arrow length unit using *scale_units*
+ and *plot_args* allows you to pass in matplotlib arguments (see
+ matplotlib.axes.Axes.quiver for more info). if *normalize* is True,
+ the fields will be scaled by their local (in-plane) length, allowing
+ morphological features to be more clearly seen for fields with
+ substantial variation in field strength.
"""
_type_name = "cquiver"
_supported_geometries = ("cartesian", "spectral_cube")
def __init__(self, field_x, field_y, factor=16, scale=None,
- scale_units=None, normalize=None):
+ scale_units=None, normalize=False, plot_args=None):
PlotCallback.__init__(self)
self.field_x = field_x
self.field_y = field_y
@@ -841,6 +870,9 @@
self.scale = scale
self.scale_units = scale_units
self.normalize = normalize
+ if plot_args is None:
+ plot_args = {}
+ self.plot_args = plot_args
def __call__(self, plot):
x0, x1 = [p.to('code_length') for p in plot.xlim]
@@ -875,7 +907,8 @@
pixX /= nn
pixY /= nn
- plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale, scale_units=self.scale_units)
+ plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale,
+ scale_units=self.scale_units, **self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
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