yt.visualization.plot_window.SlicePlot

yt.visualization.plot_window.SlicePlot(ds, normal=None, fields=None, axis=None, *args, **kwargs)[source]

A factory function for yt.visualization.plot_window.AxisAlignedSlicePlot and yt.visualization.plot_window.OffAxisSlicePlot objects. This essentially allows for a single entry point to both types of slice plots, the distinction being determined by the specified normal vector to the slice.

The returned plot object can be updated using one of the many helper functions defined in PlotWindow.

Parameters:

ds : yt.data_objects.api.Dataset

This is the dataset object corresponding to the simulation output to be plotted.

normal : int or one of ‘x’, ‘y’, ‘z’, or sequence of floats

This specifies the normal vector to the slice. If given as an integer or a coordinate string (0=x, 1=y, 2=z), this function will return an AxisAlignedSlicePlot object. If given as a sequence of floats, this is interpretted as an off-axis vector and an OffAxisSlicePlot object is returned.

fields : string

The name of the field(s) to be plotted.

axis : int or one of ‘x’, ‘y’, ‘z’

An int corresponding to the axis to slice along (0=x, 1=y, 2=z) or the axis name itself. If specified, this will replace normal.

The following are nominally keyword arguments passed onto the respective :

slice plot objects generated by this function. :

center : A sequence floats, a string, or a tuple.

The coordinate of the center of the image. If set to ‘c’, ‘center’ or left blank, the plot is centered on the middle of the domain. If set to ‘max’ or ‘m’, the center will be located at the maximum of the (‘gas’, ‘density’) field. Centering on the max or min of a specific field is supported by providing a tuple such as (“min”,”temperature”) or (“max”,”dark_matter_density”). Units can be specified by passing in center as a tuple containing a coordinate and string unit name or by passing in a YTArray. If a list or unitless array is supplied, code units are assumed.

width : tuple or a float.

Width can have four different formats to support windows with variable x and y widths. They are:

format example
(float, string) (10,’kpc’)
((float, string), (float, string)) ((10,’kpc’),(15,’kpc’))
float 0.2
(float, float) (0.2, 0.3)

For example, (10, ‘kpc’) requests a plot window that is 10 kiloparsecs wide in the x and y directions, ((10,’kpc’),(15,’kpc’)) requests a window that is 10 kiloparsecs wide along the x axis and 15 kiloparsecs wide along the y axis. In the other two examples, code units are assumed, for example (0.2, 0.3) requests a plot that has an x width of 0.2 and a y width of 0.3 in code units. If units are provided the resulting plot axis labels will use the supplied units.

axes_unit : A string

The name of the unit for the tick labels on the x and y axes. Defaults to None, which automatically picks an appropriate unit. If axes_unit is ‘1’, ‘u’, or ‘unitary’, it will not display the units, and only show the axes name.

origin : string or length 1, 2, or 3 sequence of strings

The location of the origin of the plot coordinate system for AxisAlignedSlicePlot objects; for OffAxisSlicePlot objects, this parameter is discarded. This is represented by ‘-‘ separated string or a tuple of strings. In the first index the y-location is given by ‘lower’, ‘upper’, or ‘center’. The second index is the x-location, given as ‘left’, ‘right’, or ‘center’. Finally, whether the origin is applied in ‘domain’ space, plot ‘window’ space or ‘native’ simulation coordinate system is given. For example, both ‘upper-right-domain’ and [‘upper’, ‘right’, ‘domain’] place the origin in the upper right hand corner of domain space. If x or y are not given, a value is inferred. For instance, ‘left-domain’ corresponds to the lower-left hand corner of the simulation domain, ‘center-domain’ corresponds to the center of the simulation domain, or ‘center-window’ for the center of the plot window. Further examples:

format example
‘{space}’ ‘domain’
‘{xloc}-{space}’ ‘left-window’
‘{yloc}-{space}’ ‘upper-domain’
‘{yloc}-{xloc}-{space}’ ‘lower-right-window’
(‘{space}’,) (‘window’,)
(‘{xloc}’, ‘{space}’) (‘right’, ‘domain’)
(‘{yloc}’, ‘{space}’) (‘lower’, ‘window’)
(‘{yloc}’, ‘{xloc}’, ‘{space}’) (‘lower’, ‘right’, ‘window’)

north-vector : a sequence of floats

A vector defining the ‘up’ direction in the OffAxisSlicePlot; not used in AxisAlignedSlicePlot. This option sets the orientation of the slicing plane. If not set, an arbitrary grid-aligned north-vector is chosen.

fontsize : integer

The size of the fonts for the axis, colorbar, and tick labels.

field_parameters : dictionary

A dictionary of field parameters than can be accessed by derived fields.

data_source : YTSelectionContainer Object

Object to be used for data selection. Defaults to a region covering the entire simulation.

Raises:

AssertionError :

If a proper normal axis is not specified via the normal or axis keywords, and/or if a field to plot is not specified.

Examples

>>> from yt import load
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> slc = SlicePlot(ds, "x", "density", center=[0.2,0.3,0.4])
>>>
>>> slc = SlicePlot(ds, [0.4, 0.2, -0.1], "pressure",
...                 north_vector=[0.2,-0.3,0.1])