yt.visualization.profile_plotter.ProfilePlot

class yt.visualization.profile_plotter.ProfilePlot(data_source, x_field, y_fields, weight_field='cell_mass', n_bins=64, accumulation=False, fractional=False, label=None, plot_spec=None, x_log=None, y_log=None)[source]

Create a 1d profile plot from a data source or from a list of profile objects.

Given a data object (all_data, region, sphere, etc.), an x field, and a y field (or fields), this will create a one-dimensional profile of the average (or total) value of the y field in bins of the x field.

This can be used to create profiles from given fields or to plot multiple profiles created from yt.data_objects.profiles.create_profile.

Parameters:

data_source : YTSelectionContainer Object

The data object to be profiled, such as all_data, region, or sphere.

x_field : str

The binning field for the profile.

y_fields : str or list

The field or fields to be profiled.

weight_field : str

The weight field for calculating weighted averages. If None, the profile values are the sum of the field values within the bin. Otherwise, the values are a weighted average. Default : “cell_mass”.

n_bins : int

The number of bins in the profile. Default: 64.

accumulation : bool

If True, the profile values for a bin N are the cumulative sum of all the values from bin 0 to N. Default: False.

fractional : If True the profile values are divided by the sum of all

the profile data such that the profile represents a probability distribution function.

label : str or list of strings

If a string, the label to be put on the line plotted. If a list, this should be a list of labels for each profile to be overplotted. Default: None.

plot_spec : dict or list of dicts

A dictionary or list of dictionaries containing plot keyword arguments. For example, dict(color=”red”, linestyle=”:”). Default: None.

x_log : bool

If not None, whether the x_axis should be plotted with a logarithmic scaling. Default: None

y_log : dict

A dictionary containing field:boolean pairs, setting the logarithmic property for that field. May be overridden after instantiation using set_log. Default: None

Examples

This creates profiles of a single dataset.

>>> import yt
>>> ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
>>> ad = ds.all_data()
>>> plot = ProfilePlot(ad, "density", ["temperature", "velocity_x"],
...                    weight_field="cell_mass",
...                    plot_spec=dict(color='red', linestyle="--"))
>>> plot.save()

This creates profiles from a time series object.

>>> es = yt.simulation("AMRCosmology.enzo", "Enzo")
>>> es.get_time_series()
>>> profiles = []
>>> labels = []
>>> plot_specs = []
>>> for ds in es[-4:]:
...     ad = ds.all_data()
...     profiles.append(create_profile(ad, ["density"],
...                                    fields=["temperature",
...                                            "velocity_x"]))
...     labels.append(ds.current_redshift)
...     plot_specs.append(dict(linestyle="--", alpha=0.7))
>>>
>>> plot = ProfilePlot.from_profiles(profiles, labels=labels,
...                                  plot_specs=plot_specs)
>>> plot.save()

Use set_line_property to change line properties of one or all profiles.

Attributes

Methods