Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: allow passing a dataset as a data source to ParticlePhasePlot #4119

Merged
merged 1 commit into from
Sep 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions yt/visualization/particle_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np

from yt.data_objects.profiles import create_profile
from yt.data_objects.static_output import Dataset
from yt.funcs import fix_axis, iter_fields
from yt.units.yt_array import YTArray
from yt.visualization.fixed_resolution import ParticleImageBuffer
Expand Down Expand Up @@ -314,9 +315,9 @@ class ParticlePhasePlot(PhasePlot):

Parameters
----------
data_source : YTSelectionContainer Object
data_source : YTSelectionContainer or Dataset
The data object to be profiled, such as all_data, region, or
sphere.
sphere. If data_source is a Dataset, data_source.all_data() will be used.
x_field : str
The x field for the mesh.
y_field : str
Expand Down Expand Up @@ -403,6 +404,8 @@ def __init__(
shading="nearest",
):

if isinstance(data_source, Dataset):
data_source = data_source.all_data()
# if no z_fields are passed in, use a constant color
if z_fields is None:
self.use_cbar = False
Expand Down