yt.visualization.plot_window.AxisAlignedSlicePlot

class yt.visualization.plot_window.AxisAlignedSlicePlot(ds, axis, fields, center='c', width=None, axes_unit=None, origin='center-window', fontsize=18, field_parameters=None, window_size=8.0, aspect=None, data_source=None)[source]

Creates a slice plot from a dataset

Given a ds object, an axis to slice along, and a field name string, this will return a PWViewerMPL object containing the plot.

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

Parameters:

ds : Dataset

This is the dataset object corresponding to the simulation output 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

fields : string

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

center : A sequence of 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. 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, the default location ‘center-window’ corresponds to the center of the plot window, ‘left-domain’ corresponds to the lower-left hand corner of the simulation domain, or ‘center-domain’ for the center of the simulation domain. 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’)

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.

Examples

This will save an image in the file ‘sliceplot_Density.png’

>>> from yt import load
>>> ds = load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> p = SlicePlot(ds, 2, 'density', 'c', (20, 'kpc'))
>>> p.save('sliceplot')

Methods