Callbacks to add additional functionality on to plots.
yt.visualization.plot_modifications.
ArrowCallback
(pos, code_size=None, length=0.03, width=0.0001, head_width=0.01, head_length=0.01, starting_pos=None, coord_system='data', plot_args=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Overplot an arrow pointing at a position for highlighting a specific feature. By default, arrow points from lower left to the designated position “pos” with arrow length “length”. Alternatively, if “starting_pos” is set, arrow will stretch from “starting_pos” to “pos” and “length” will be disregarded.
“coord_system” keyword refers to positions set in “pos” arg and “starting_pos” keyword, which by default are in data coordinates.
“length”, “width”, “head_length”, and “head_width” keywords for the arrow are all in axis units, ie relative to the size of the plot axes as 1, even if the position of the arrow is set relative to another coordinate system.
Parameters: 


Examples
>>> # Overplot an arrow pointing to feature at data coord: (0.2, 0.3, 0.4)
>>> import yt
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_arrow([0.2,0.3,0.4])
>>> s.save()
>>> # Overplot a red arrow with longer length pointing to plot coordinate
>>> # (0.1, 0.1)
>>> import yt
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_arrow([0.1, 0.1], length=0.06, coord_system='plot',
... plot_args={'color':'red'})
>>> s.save()
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
CellEdgesCallback
(line_width=0.002, alpha=1.0, color='black')[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Annotate cell edges. This is done through a second call to pixelize, where the distance from a pixel to a cell boundary in pixels is compared against the line_width argument. The secondary image is colored as color and overlaid with the alpha value.
Parameters: 


Examples
>>> import yt
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_cell_edges()
>>> s.save()
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
ClumpContourCallback
(clumps, plot_args=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Take a list of clumps and plot them as a set of contours.
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
ContourCallback
(field, ncont=5, factor=4, clim=None, plot_args=None, label=False, take_log=None, label_args=None, text_args=None, data_source=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
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. An alternate data source can be specified with data_source, but by default the plot’s data source will be queried.
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
CuttingQuiverCallback
(field_x, field_y, factor=16, scale=None, scale_units=None, normalize=False, plot_args=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
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 (inplane) length, allowing morphological features to be more clearly seen for fields with substantial variation in field strength.
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
GridBoundaryCallback
(alpha=0.7, min_pix=1, min_pix_ids=20, draw_ids=False, id_loc='lower left', periodic=True, min_level=None, max_level=None, cmap='BW LINEAR_r', edgecolors=None, linewidth=1.0)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Draws grids on an existing PlotWindow object. Adds grid boundaries to a plot, optionally with alphablending. By default, colors different levels of grids with different colors going from white to black, but you can change to any arbitrary colormap with cmap keyword, to all black grid edges for all levels with cmap=None and edgecolors=None, or to an arbitrary single color for grid edges with edgecolors=’YourChosenColor’ defined in any of the standard ways (e.g., edgecolors=’white’, edgecolors=’r’, edgecolors=’#00FFFF’, or edgecolor=‘0.3’, where the last is a float in 01 scale indicating gray). Note that setting edgecolors overrides cmap if you have both set to nonNone values. Cutoff for display is at min_pix wide. draw_ids puts the grid id a the corner of the grid (but its not so great in projections...). id_loc determines which corner holds the grid id. One can set min and maximum level of grids to display, and can change the linewidth of the displayed grids.
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
HaloCatalogCallback
(halo_catalog, circle_args=None, circle_kwargs=None, width=None, annotate_field=None, radius_field='virial_radius', center_field_prefix='particle_position', text_args=None, font_kwargs=None, factor=1.0)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Plots circles at the locations of all the halos in a halo catalog with radii corresponding to the virial radius of each halo.
Parameters: 


Examples
>>> import yt
>>> dds = yt.load("Enzo_64/DD0043/data0043")
>>> hds = yt.load("rockstar_halos/halos_0.0.bin")
>>> p = yt.ProjectionPlot(dds, "x", "density", weight_field="density")
>>> p.annotate_halos(hds)
>>> p.save()
>>> # plot a subset of all halos
>>> import yt
>>> dds = yt.load("Enzo_64/DD0043/data0043")
>>> hds = yt.load("rockstar_halos/halos_0.0.bin")
>>> # make a region half the width of the box
>>> dregion = dds.box(dds.domain_center  0.25*dds.domain_width,
... dds.domain_center + 0.25*dds.domain_width)
>>> hregion = hds.box(hds.domain_center  0.25*hds.domain_width,
... hds.domain_center + 0.25*hds.domain_width)
>>> p = yt.ProjectionPlot(dds, "x", "density", weight_field="density",
... data_source=dregion, width=0.5)
>>> p.annotate_halos(hregion)
>>> p.save()
>>> # plot halos from a HaloCatalog
>>> import yt
>>> from yt.analysis_modules.halo_analysis.api import HaloCatalog
>>> dds = yt.load("Enzo_64/DD0043/data0043")
>>> hds = yt.load("rockstar_halos/halos_0.0.bin")
>>> hc = HaloCatalog(data_ds=dds, halos_ds=hds)
>>> p = yt.ProjectionPlot(dds, "x", "density", weight_field="density")
>>> p.annotate_halos(hc)
>>> p.save()
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
region
= None¶sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
ImageLineCallback
(p1, p2, data_coords=False, coord_system='axis', plot_args=None)[source]¶Bases: yt.visualization.plot_modifications.LinePlotCallback
This callback is deprecated, as it is simply a wrapper around the LinePlotCallback (ie annotate_image()). The only difference is that it uses coord_system=”axis” by default. Please see LinePlotCallback for more information.
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
LineIntegralConvolutionCallback
(field_x, field_y, texture=None, kernellen=50.0, lim=(0.5, 0.6), cmap='binary', alpha=0.8, const_alpha=False)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Add the line integral convolution to the plot for vector fields visualization. Two component of vector fields needed to be provided (i.e., velocity_x and velocity_y, magnetic_field_x and magnetic_field_y).
Parameters: 


Example
>>> import yt
>>> ds = yt.load('Enzo_64/DD0020/data0020')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_line_integral_convolution('velocity_x', 'velocity_y', lim=(0.5,0.65))
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
LinePlotCallback
(p1, p2, data_coords=False, coord_system='data', plot_args=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Overplot a line with endpoints at p1 and p2. p1 and p2 should be 2D or 3D coordinates consistent with the coordinate system denoted in the “coord_system” keyword.
Parameters: 


Examples
>>> # Overplot a diagonal white line from the lower left corner to upper
>>> # right corner
>>> import yt
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_line([0,0], [1,1], coord_system='axis')
>>> s.save()
>>> # Overplot a red dashed line from data coordinate (0.1, 0.2, 0.3) to
>>> # (0.5, 0.6, 0.7)
>>> import yt
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_line([0.1, 0.2, 0.3], [0.5, 0.6, 0.7], coord_system='data',
plot_args={'color':'red', 'lineStyles':''})
>>> s.save()
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
MagFieldCallback
(factor=16, scale=None, scale_units=None, normalize=False, plot_args=None)[source]¶Bases: yt.visualization.plot_modifications.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 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 (inplane) length, allowing morphological features to be more clearly seen for fields with substantial variation in field strength.
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
MarkerAnnotateCallback
(pos, marker='x', coord_system='data', plot_args=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Overplot a marker on a position for highlighting specific features.
Parameters: 


Examples
>>> # Overplot a white X on a feature at data location (0.5, 0.5, 0.5)
>>> import yt
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_marker([0.4, 0.5, 0.6])
>>> s.save()
>>> # Overplot a big yellow circle at axis location (0.1, 0.2)
>>> import yt
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_marker([0.1, 0.2], marker='o', coord_system='axis',
... plot_args={'color':'yellow', 's':200})
>>> s.save()
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
MeshLinesCallback
(plot_args=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Adds mesh lines to the plot. Only works for unstructured or semistructured mesh data. For structured grid data, see GridBoundaryCallback or CellEdgesCallback.
Parameters:  plot_args (dict, optional) – A dictionary of arguments that will be passed to matplotlib. 

Example
>>> import yt
>>> ds = yt.load("MOOSE_sample_data/out.es010")
>>> sl = yt.SlicePlot(ds, 'z', ('connect2', 'convected'))
>>> sl.annotate_mesh_lines(plot_args={'color':'black'})
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
ParticleCallback
(width, p_size=1.0, col='k', marker='o', stride=1, ptype='all', minimum_mass=None, alpha=1.0, data_source=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
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. alpha determines the opacity of the marker symbol used in the scatter. An alternate data source can be specified with data_source, but by default the plot’s data source will be queried.
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
region
= None¶sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
PlotCallback
(*args, **kwargs)[source]¶Bases: object
convert_to_plot
(plot, coord, offset=True)[source]¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
project_coords
(plot, coord)[source]¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)[source]¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
PointAnnotateCallback
(pos, text, data_coords=False, coord_system='data', text_args=None, inset_box_args=None)[source]¶Bases: yt.visualization.plot_modifications.TextLabelCallback
This callback is deprecated, as it is simply a wrapper around the TextLabelCallback (ie annotate_text()). Please see TextLabelCallback for more information.
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
QuiverCallback
(field_x, field_y, factor=16, scale=None, scale_units=None, normalize=False, bv_x=0, bv_y=0, plot_args=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
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 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 (inplane) length, allowing morphological features to be more clearly seen for fields with substantial variation in field strength.
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
RayCallback
(ray, arrow=False, plot_args=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Adds a line representing the projected path of a ray across the plot. The ray can be either a YTOrthoRay, YTRay, or a LightRay object. annotate_ray() will properly account for periodic rays across the volume. If arrow is set to True, uses the MPL.pyplot.arrow function, otherwise uses the MPL.pyplot.plot function to plot a normal line. Adjust plot_args accordingly.
Parameters: 


Examples
>>> # Overplot a ray and an ortho_ray object on a projection
>>> import yt
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> oray = ds.ortho_ray(1, (0.3, 0.4)) # orthoray down the y axis
>>> ray = ds.ray((0.1, 0.2, 0.3), (0.6, 0.7, 0.8)) # arbitrary ray
>>> p = yt.ProjectionPlot(ds, 'z', 'density')
>>> p.annotate_ray(oray)
>>> p.annotate_ray(ray)
>>> p.save()
>>> # Overplot a LightRay object on a projection
>>> import yt
>>> from yt.analysis_modules.cosmological_observation.api import LightRay
>>> ds = yt.load('enzo_cosmology_plus/RD0004/RD0004')
>>> lr = LightRay("enzo_cosmology_plus/AMRCosmology.enzo",
... 'Enzo', 0.0, 0.1, time_data=False)
>>> lray = lr.make_light_ray(seed=1)
>>> p = yt.ProjectionPlot(ds, 'z', 'density')
>>> p.annotate_ray(lr)
>>> p.save()
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
RegisteredCallback
(name, b, d)[source]¶Bases: type
mro
() → list¶return a type’s method resolution order
yt.visualization.plot_modifications.
ScaleCallback
(corner='lower_right', coeff=None, unit=None, pos=None, max_frac=0.16, min_frac=0.015, coord_system='axis', text_args=None, size_bar_args=None, draw_inset_box=False, inset_box_args=None, scale_text_format='{scale} {units}')[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Annotates the scale of the plot at a specified location in the image (either in a preset corner, or by specifying (x,y) image coordinates with the pos argument. Coeff and units (e.g. 1 Mpc or 100 kpc) refer to the distance scale you desire to show on the plot. If no coeff and units are specified, an appropriate pair will be determined such that your scale bar is never smaller than min_frac or greater than max_frac of your plottable axis length. Additional customization of the scale bar is possible by adjusting the text_args and size_bar_args dictionaries. The text_args dictionary accepts matplotlib’s font_properties arguments to override the default font_properties for the current plot. The size_bar_args dictionary accepts keyword arguments for the AnchoredSizeBar class in matplotlib’s axes_grid toolkit.
Parameters: 


Example
>>> import yt
>>> ds = yt.load('Enzo_64/DD0020/data0020')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_scale()
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
SphereCallback
(center, radius, circle_args=None, text=None, coord_system='data', text_args=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Overplot a circle with designated center and radius with optional text.
Parameters: 


Examples
>>> # Overplot a white circle of radius 100 kpc over the central galaxy
>>> import yt
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_sphere([0.5, 0.5, 0.5], radius=(100, 'kpc'))
>>> s.save()
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
StreamlineCallback
(field_x, field_y, factor=16, density=1, field_color=None, display_threshold=None, plot_args=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Add streamlines to any plot, using the field_x and field_y from the associated data, skipping every factor datapoints like ‘quiver’. density is the index of the amount of the streamlines. field_color is a field to be used to colormap the streamlines. If display_threshold is supplied, any streamline segments where field_color is less than the threshold will be removed by having their line width set to 0.
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
TextLabelCallback
(pos, text, data_coords=False, coord_system='data', text_args=None, inset_box_args=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Overplot text on the plot at a specified position. If you desire an inset box around your text, set one with the inset_box_args dictionary keyword.
Parameters: 


Examples
>>> # Overplot white text at data location [0.55, 0.7, 0.4]
>>> import yt
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_text([0.55, 0.7, 0.4], "Here is a galaxy")
>>> s.save()
>>> # Overplot yellow text at axis location [0.2, 0.8] with
>>> # a shaded inset box
>>> import yt
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_text([0.2, 0.8], "Here is a galaxy", coord_system='axis',
... text_args={'color':'yellow'},
... inset_box_args={'boxstyle':'square,pad=0.3',
... 'facecolor':'black',
... 'linewidth':3,
... 'edgecolor':'white', 'alpha':0.5})
>>> s.save()
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
TimestampCallback
(x_pos=None, y_pos=None, corner='lower_left', time=True, redshift=False, time_format='t = {time:.1f} {units}', time_unit=None, redshift_format='z = {redshift:.2f}', draw_inset_box=False, coord_system='axis', time_offset=None, text_args=None, inset_box_args=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Annotates the timestamp and/or redshift of the data output at a specified location in the image (either in a present corner, or by specifying (x,y) image coordinates with the x_pos, y_pos arguments. If no time_units are specified, it will automatically choose appropriate units. It allows for custom formatting of the time and redshift information, as well as the specification of an inset box around the text.
Parameters: 


Example
>>> import yt
>>> ds = yt.load('Enzo_64/DD0020/data0020')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_timestamp()
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
TitleCallback
(title)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Accepts a title and adds it to the plot
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
TriangleFacetsCallback
(triangle_vertices, plot_args=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
Intended for representing a slice of a triangular faceted geometry in a slice plot.
Uses a set of triangle_vertices to find all triangles the plane of a SlicePlot intersects with. The lines between the intersection points of the triangles are then added to the plot to create an outline of the geometry represented by the triangles.
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 


yt.visualization.plot_modifications.
VelocityCallback
(factor=16, scale=None, scale_units=None, normalize=False, plot_args=None)[source]¶Bases: yt.visualization.plot_modifications.PlotCallback
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 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 (inplane) length, allowing morphological features to be more clearly seen for fields with substantial variation in field strength.
convert_to_plot
(plot, coord, offset=True)¶Convert coordinates from projected data coordinates to PlotWindow plot coordinates. Projected data coordinates are two dimensional and refer to the location relative to the specific axes being plotted, although still in simulation units. PlotWindow plot coordinates are locations as found in the final plot, usually with the origin in the center of the image and the extent of the image defined by the final plot axis markers.
pixel_scale
(plot)¶project_coords
(plot, coord)¶Convert coordinates from simulation data coordinates to projected data coordinates. Simulation data coordinates are three dimensional, and can either be specified as a YTArray or as a list or array in code_length units. Projected data units are 2D versions of the simulation data units relative to the axes of the final plot.
sanitize_coord_system
(plot, coord, coord_system)¶Given a set of x,y (and z) coordinates and a coordinate system, convert the coordinates (and transformation) ready for final plotting.
Parameters: 

