yt.visualization.plot_window.ProjectionPlot

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

Creates a projection plot from a dataset

Given a ds object, an axis to project 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, ‘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’)

data_source : YTSelectionContainer Object

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

weight_field : string

The name of the weighting field. Set to None for no weight.

max_level: int :

The maximum level to project to.

fontsize : integer

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

method : string

The method of projection. Valid methods are:

“integrate” with no weight_field specified : integrate the requested field along the line of sight.

“integrate” with a weight_field specified : weight the requested field by the weighting field and integrate along the line of sight.

“mip” : pick out the maximum value of the field in the line of sight.

“sum” : This method is the same as integrate, except that it does not multiply by a path length when performing the integration, and is just a straight summation of the field along the given axis. WARNING: This should only be used for uniform resolution grid datasets, as other datasets may result in unphysical images.

proj_style : string

The method of projection–same as method keyword. Deprecated as of version 3.0.2. Please use method instead.

window_size : float

The size of the window in inches. Set to 8 by default.

aspect : float

The aspect ratio of the plot. Set to None for 1.

field_parameters : dictionary

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

Examples

Create a projection plot with a width of 20 kiloparsecs centered on the center of the simulation box:

>>> from yt import load
>>> ds = load('IsolateGalaxygalaxy0030/galaxy0030')
>>> p = ProjectionPlot(ds, "z", "density", width=(20, "kpc"))

Methods