Plot Modification Mechanisms

Because the plots in yt are considered to be “volatile” – existing independent of the canvas on which they are plotted – before they are saved, you can have a set of “callbacks” run that modify them before saving to disk. By adding a callback, you are telling the plot that whatever it does it itself, your callback gets the last word.

These can all be accessed through a registry attached to every plot object. When you add a plot to a yt.raven.PlotCollection, you get back that affiliated plot object. By accessing modify on that plot object, you have access to the available callbacks. For instance,

p = PlotCollection.add_slice("Density", 0)
p.modify["velocity"]()

would add the velocity() callback to the plot object. When you save the plot, the list of callbacks will be iterated over, and the velocity callback will be handed the current state of the plot. It will then be able to dynamically modify the plot before saving – in this case, adding on velocity vectors atop the image.

Available Callbacks

These are the callbacks available through the modify[] mechanism. The underlying functions are documented (largely identical to this) in callback-api.

arrow(self, pos, code_size, plot_args=None):

(This is a proxy for yt.raven.Callbacks.ArrowCallback.) This adds an arrow pointing at pos with size code_size in code units. plot_args is a dict fed to matplotlib with arrow properties.

clumps(self, clumps, plot_args=None):

(This is a proxy for yt.raven.Callbacks.ClumpContourCallback.) Take a list of clumps and plot them as a set of contours.

contour(self, field, ncont=5, factor=4, take_log=False, clim=None, plot_args=None):

(This is a proxy for yt.raven.Callbacks.ContourCallback.) Add contours in field to the plot. ncont governs the number of contours generated, factor governs the number of points used in the interpolation, take_log governs how it is contoured and clim gives the (upper, lower) limits for contouring.

coord_axes(self, unit=None, coords=False):

(This is a proxy for yt.raven.Callbacks.CoordAxesCallback.) Creates x and y axes for a VMPlot. In the future, it will attempt to guess the proper units to use.

cquiver(self, field_x, field_y, factor):

(This is a proxy for yt.raven.Callbacks.CuttingQuiverCallback.) Get a quiver plot on top of a cutting plane, using field_x and field_y, skipping every factor datapoint in the discretization.

grids(self, alpha=1.0, min_pix=1, annotate=False, periodic=True):

(This is a proxy for yt.raven.Callbacks.GridBoundaryCallback.) Adds grid boundaries to a plot, optionally with alpha-blending. Cuttoff for display is at min_pix wide. annotate puts the grid id in the corner of the grid. (Not so great in projections...)

hop_circles(self, hop_output, max_number=None, annotate=False, min_size=20, max_size=10000000, font_size=8, print_halo_size=False, print_halo_mass=False, width=None):

(This is a proxy for yt.raven.Callbacks.HopCircleCallback.) Accepts a yt.lagos.HopList hop_output and plots up to max_number (None for unlimited) halos as circles.

hop_particles(self, hop_output, p_size=1.0, max_number=None, min_size=20, alpha=0.20000000000000001):

(This is a proxy for yt.raven.Callbacks.HopParticleCallback.) Adds particle positions for the members of each halo as identified by HOP. Along axis up to max_number groups in hop_output that are larger than min_size are plotted with p_size pixels per particle; alpha determines the opacity of each particle.

axis_label(self, label):

(This is a proxy for yt.raven.Callbacks.LabelCallback.) This adds a label to the plot.

line(self, x, y, plot_args=None):

(This is a proxy for yt.raven.Callbacks.LinePlotCallback.) Over plot x and y with plot_args fed into the plot.

marker(self, pos, marker='x', plot_args=None):

(This is a proxy for yt.raven.Callbacks.MarkerAnnotateCallback.) Adds text marker at pos in code-arguments. plot_args is a dict that will be forwarded to the plot command.

particles(self, width, p_size=1.0, col='k', stride=1.0, ptype=None, stars_only=False, dm_only=False):

(This is a proxy for yt.raven.Callbacks.ParticleCallback.) Adds particle positions, based on a thick slab along axis with a width along the line of sight. p_size controls the number of pixels per particle, and col governs the color. ptype will restrict plotted particles to only those that are of a given type.

point(self, pos, text, text_args=None):

(This is a proxy for yt.raven.Callbacks.PointAnnotateCallback.) This adds text at position pos, where pos is in code-space. text_args is a dict fed to the text placement code.

quiver(self, field_x, field_y, factor):

(This is a proxy for yt.raven.Callbacks.QuiverCallback.) Adds a ‘quiver’ plot to any plot, using the field_x and field_y from the associated data, skipping every factor datapoints.

sphere(self, center, radius, circle_args=None, text=None, text_args=None):

(This is a proxy for yt.raven.Callbacks.SphereCallback.) A sphere centered at center in code units with radius radius in code units will be created, with optional circle_args, text, and text_args.

text(self, pos, text, text_args=None):

(This is a proxy for yt.raven.Callbacks.TextLabelCallback.) Accepts a position in (0..1, 0..1) of the image, some text and optionally some text arguments.

title(self, title='Plot'):

(This is a proxy for yt.raven.Callbacks.TitleCallback.) Accepts a title and adds it to the plot

units(self, unit='au', factor=4, text_annotate=True, text_which=-2):

(This is a proxy for yt.raven.Callbacks.UnitBoundaryCallback.) Add on a plot indicating where factor*s of *unit are shown. Optionally text_annotate on the text_which-indexed box on display.

velocity(self, factor=16):

(This is a proxy for yt.raven.Callbacks.VelocityCallback.) Adds a ‘quiver’ plot of velocity to the plot, skipping all but every factor datapoint

voboz_circle(self, voboz_output, max_number=None, annotate=False, min_size=20, font_size=8, print_halo_size=False):

(This is a proxy for yt.raven.Callbacks.VobozCircleCallback.) x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Table Of Contents

Previous topic

Derived Quantities

Next topic

The Plugin File

This Page