diff --git a/yt/visualization/profile_plotter.py b/yt/visualization/profile_plotter.py index 8d2ef567b4..dcfbc9c32b 100644 --- a/yt/visualization/profile_plotter.py +++ b/yt/visualization/profile_plotter.py @@ -1319,8 +1319,6 @@ def annotate_title(self, title): """ for f in self._profile.field_data: - if isinstance(f, tuple): - f = f[1] self.plot_title[self.data_source._determine_fields(f)[0]] = title return self diff --git a/yt/visualization/tests/test_profile_plots.py b/yt/visualization/tests/test_profile_plots.py index 6c25bfbefc..96fea028b8 100644 --- a/yt/visualization/tests/test_profile_plots.py +++ b/yt/visualization/tests/test_profile_plots.py @@ -3,10 +3,11 @@ import tempfile import unittest +import numpy as np import pytest import yt -from yt.testing import assert_allclose_units, fake_random_ds +from yt.testing import assert_allclose_units, fake_random_ds, fake_random_sph_ds from yt.visualization.api import PhasePlot @@ -66,6 +67,61 @@ def test_phaseplot_set_ylim(self): return p.plots["gas", "mass"].figure +class TestPhasePlotParticleAPI: + @classmethod + def setup_class(cls): + bbox = np.array([[-1.0, 3.0], [1.0, 5.2], [-1.0, 3.0]]) + cls.ds = fake_random_sph_ds(50, bbox) + + def get_plot(self): + return PhasePlot( + self.ds, ("gas", "density"), ("gas", "density"), ("gas", "mass") + ) + + @pytest.mark.parametrize("kwargs", [{}, {"color": "b"}]) + @pytest.mark.mpl_image_compare + def test_phaseplot_annotate_text(self, kwargs): + p = self.get_plot() + p.annotate_text(1e-4, 1e-2, "Test text annotation", **kwargs) + p.render() + return p.plots["gas", "mass"].figure + + @pytest.mark.mpl_image_compare + def test_phaseplot_set_title(self): + p = self.get_plot() + p.annotate_title("Test Title") + p.render() + return p.plots["gas", "mass"].figure + + @pytest.mark.mpl_image_compare + def test_phaseplot_set_log(self): + p = self.get_plot() + p.set_log(("gas", "mass"), False) + p.render() + return p.plots["gas", "mass"].figure + + @pytest.mark.mpl_image_compare + def test_phaseplot_set_unit(self): + p = self.get_plot() + p.set_unit(("gas", "mass"), "Msun") + p.render() + return p.plots["gas", "mass"].figure + + @pytest.mark.mpl_image_compare + def test_phaseplot_set_xlim(self): + p = self.get_plot() + p.set_xlim(1e-3, 1e0) + p.render() + return p.plots["gas", "mass"].figure + + @pytest.mark.mpl_image_compare + def test_phaseplot_set_ylim(self): + p = self.get_plot() + p.set_ylim(1e-2, 1e0) + p.render() + return p.plots["gas", "mass"].figure + + def test_set_units(): fields = ("density", "temperature") units = (