[yt-svn] commit/yt: 5 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Feb 22 06:46:39 PST 2018


5 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/ca42afb48052/
Changeset:   ca42afb48052
User:        ash
Date:        2018-02-21 15:30:16+00:00
Summary:     added set_*label feature to the profileplot. Addresses issue #1298
Affected #:  1 file

diff -r f4996439257b315b7e3982e21662d139f7855205 -r ca42afb48052acffe0d5ebe7907d9e93bc06075c yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -209,10 +209,11 @@
     Use set_line_property to change line properties of one or all profiles.
     
     """
+
     x_log = None
     y_log = None
-    x_title = None
-    y_title = None
+    x_title = {}
+    y_title = {}
     _plot_valid = False
 
     def __init__(self, data_source, x_field, y_fields,
@@ -359,10 +360,13 @@
                 axes = self.axes[fname]
                 xscale, yscale = self._get_field_log(fname, profile)
                 xtitle, ytitle = self._get_field_title(fname, profile)
+
                 axes.set_xscale(xscale)
                 axes.set_yscale(yscale)
+
+                axes.set_ylabel(ytitle)
                 axes.set_xlabel(xtitle)
-                axes.set_ylabel(ytitle)
+
                 axes.set_ylim(*self.axes.ylim[fname])
                 axes.set_xlim(*self.axes.xlim)
                 if any(self.label):
@@ -501,6 +505,46 @@
                 raise KeyError("Field %s not in profile plot!" % (field))
         return self
 
+
+    @invalidate_plot
+    def set_ylabel(self, field, label):
+        """
+
+        """
+        if field == "all":
+            for field in list(self.profiles[0].field_data.keys()):
+                print(field)
+                self.y_title[field] = label
+        else:
+            field, = self.profiles[0].data_source._determine_fields([field])
+            if field in self.profiles[0].field_data:
+                self.y_title[field] = label
+            else:
+                raise KeyError("Field %s not in profile plot!" % (field))
+
+        _plot_valid = False
+
+        return self
+
+    @invalidate_plot
+    def set_xlabel(self, field, label):
+        """
+
+        """
+        if field == "all":
+            for field in list(self.profiles[0].field_data.keys()):
+                self.x_title[field] = label
+        else:
+            field, = self.profiles[0].data_source._determine_fields([field])
+            if field in self.profiles[0].field_data:
+                self.x_title[field] = label
+            else:
+                raise KeyError("Field %s not in profile plot!" % (field))
+
+        _plot_valid = False
+
+        return self
+
     @invalidate_plot
     def set_unit(self, field, unit):
         """Sets a new unit for the requested field
@@ -662,7 +706,7 @@
         x_unit = profile.x.units
         y_unit = profile.field_units[field_y]
         fractional = profile.fractional
-        x_title = self.x_title or self._get_field_label(field_x, xfi, x_unit)
+        x_title = self.x_title.get(field_y, None) or self._get_field_label(field_x, xfi, x_unit)
         y_title = self.y_title.get(field_y, None) or \
             self._get_field_label(field_y, yfi, y_unit, fractional)
 


https://bitbucket.org/yt_analysis/yt/commits/b2477ceb9541/
Changeset:   b2477ceb9541
User:        ash
Date:        2018-02-21 22:32:37+00:00
Summary:     modified label implementation of profileplot to be more inline with the yt style. Also added documentation, doc strings and a unit test for the implenetation. Addresses issue #1298
Affected #:  3 files

diff -r ca42afb48052acffe0d5ebe7907d9e93bc06075c -r b2477ceb95417185b13436a5bf8046a36ac9aed0 doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -1074,6 +1074,31 @@
    plot.set_log("x-velocity", False)
    plot.save()
 
+Setting axis labels
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The axis labels can be manipulated via the
+:meth:`~yt.visualization.profile_plotter.ProfilePlot.set_ylabel` and
+:meth:`~yt.visualization.profile_plotter.ProfilePlot.set_xlabel` functions.  The
+:meth:`~yt.visualization.profile_plotter.ProfilePlot.set_ylabel` function accepts a field name 
+and a string with the desired label. The :meth:`~yt.visualization.profile_plotter.ProfilePlot.set_xlabel`
+function just accepts the desired label and applies this to all of the plots. 
+
+In the following example we create a plot of the average x velocity and density as a
+function of radius. The xlabel is set to "Radius" for all plots and the ylabel is set to
+"velocity in x direction" for the x-velocity plot.
+
+.. python-script::
+
+  import yt
+  ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
+  ad = ds.all_data()
+  plot = yt.ProfilePlot(ad, "density", ["temperature", "velocity_x"],
+                   weight_field=None)
+   plot.set_xlabel(r"Radius")
+   plot.set_ylabel("x-velocity", "velocity in x direction")
+   plot.save()
+
 Altering Line Properties
 ~~~~~~~~~~~~~~~~~~~~~~~~
 

diff -r ca42afb48052acffe0d5ebe7907d9e93bc06075c -r b2477ceb95417185b13436a5bf8046a36ac9aed0 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -212,8 +212,8 @@
 
     x_log = None
     y_log = None
-    x_title = {}
-    y_title = {}
+    x_title = None
+    y_title = None
     _plot_valid = False
 
     def __init__(self, data_source, x_field, y_fields,
@@ -387,6 +387,7 @@
                 field, = obj.profiles[0].data_source._determine_fields([field])
                 obj.y_log[field] = log
         obj.y_title = {}
+        obj.x_title = None
         obj.label = sanitize_label(labels, len(obj.profiles))
         if plot_specs is None:
             plot_specs = [dict() for p in obj.profiles]
@@ -508,12 +509,18 @@
 
     @invalidate_plot
     def set_ylabel(self, field, label):
-        """
+        """Sets a new ylabel for the specified fields
 
+        Parameters
+        ----------
+        field : string
+           The name of the field that is to be changed.
+
+        label : string
+           The label to be placed on the y-axis
         """
         if field == "all":
             for field in list(self.profiles[0].field_data.keys()):
-                print(field)
                 self.y_title[field] = label
         else:
             field, = self.profiles[0].data_source._determine_fields([field])
@@ -522,26 +529,18 @@
             else:
                 raise KeyError("Field %s not in profile plot!" % (field))
 
-        _plot_valid = False
-
         return self
 
     @invalidate_plot
-    def set_xlabel(self, field, label):
-        """
+    def set_xlabel(self, label):
+        """Sets a new xlabel for all profiles
 
+        Parameters
+        ----------
+        label : string
+           The label to be placed on the x-axis
         """
-        if field == "all":
-            for field in list(self.profiles[0].field_data.keys()):
-                self.x_title[field] = label
-        else:
-            field, = self.profiles[0].data_source._determine_fields([field])
-            if field in self.profiles[0].field_data:
-                self.x_title[field] = label
-            else:
-                raise KeyError("Field %s not in profile plot!" % (field))
-
-        _plot_valid = False
+        self.x_title = label
 
         return self
 
@@ -706,7 +705,7 @@
         x_unit = profile.x.units
         y_unit = profile.field_units[field_y]
         fractional = profile.fractional
-        x_title = self.x_title.get(field_y, None) or self._get_field_label(field_x, xfi, x_unit)
+        x_title = self.x_title or self._get_field_label(field_x, xfi, x_unit)
         y_title = self.y_title.get(field_y, None) or \
             self._get_field_label(field_y, yfi, y_unit, fractional)
 

diff -r ca42afb48052acffe0d5ebe7907d9e93bc06075c -r b2477ceb95417185b13436a5bf8046a36ac9aed0 yt/visualization/tests/test_profile_plots.py
--- a/yt/visualization/tests/test_profile_plots.py
+++ b/yt/visualization/tests/test_profile_plots.py
@@ -169,4 +169,12 @@
     p2 = yt.PhasePlot(sp, ("enzo", "Density"), ("enzo", "Temperature"), "cell_mass")
     # make sure we can set the units using the tuple without erroring out
     p1.set_unit(("enzo", "Density"), "Msun/kpc**3")
-    p2.set_unit(("enzo", "Temperature"), "R")
\ No newline at end of file
+    p2.set_unit(("enzo", "Temperature"), "R")
+
+def test_set_labels():
+ds = fake_random_ds(16)
+    ad = ds.all_data()
+    plot = yt.ProfilePlot(ad, "radius", ["velocity_x", "density"], weight_field=None)
+    # make sure we can set the labels without erroring out
+    plot.set_ylabel("all", "test ylabel")
+    plot.set_xlabel("test xlabel")
\ No newline at end of file


https://bitbucket.org/yt_analysis/yt/commits/b2b638026c53/
Changeset:   b2b638026c53
User:        ash
Date:        2018-02-21 22:38:08+00:00
Summary:     modified label example in profileplot set_*label documentation and fixed some minor indenting issue. Addresses issue #1298
Affected #:  2 files

diff -r b2477ceb95417185b13436a5bf8046a36ac9aed0 -r b2b638026c53ad3c221da58cb5019d0e3bd36da7 doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -1084,8 +1084,8 @@
 and a string with the desired label. The :meth:`~yt.visualization.profile_plotter.ProfilePlot.set_xlabel`
 function just accepts the desired label and applies this to all of the plots. 
 
-In the following example we create a plot of the average x velocity and density as a
-function of radius. The xlabel is set to "Radius" for all plots and the ylabel is set to
+In the following example we create a plot of the average x-velocity and density as a
+function of radius. The xlabel is set to "Radius", for all plots, and the ylabel is set to
 "velocity in x direction" for the x-velocity plot.
 
 .. python-script::
@@ -1095,7 +1095,7 @@
   ad = ds.all_data()
   plot = yt.ProfilePlot(ad, "density", ["temperature", "velocity_x"],
                    weight_field=None)
-   plot.set_xlabel(r"Radius")
+   plot.set_xlabel("Radius")
    plot.set_ylabel("x-velocity", "velocity in x direction")
    plot.save()
 

diff -r b2477ceb95417185b13436a5bf8046a36ac9aed0 -r b2b638026c53ad3c221da58cb5019d0e3bd36da7 yt/visualization/tests/test_profile_plots.py
--- a/yt/visualization/tests/test_profile_plots.py
+++ b/yt/visualization/tests/test_profile_plots.py
@@ -172,7 +172,7 @@
     p2.set_unit(("enzo", "Temperature"), "R")
 
 def test_set_labels():
-ds = fake_random_ds(16)
+    ds = fake_random_ds(16)
     ad = ds.all_data()
     plot = yt.ProfilePlot(ad, "radius", ["velocity_x", "density"], weight_field=None)
     # make sure we can set the labels without erroring out


https://bitbucket.org/yt_analysis/yt/commits/64cd3c2da8f2/
Changeset:   64cd3c2da8f2
User:        ash
Date:        2018-02-22 00:57:52+00:00
Summary:     fixed indenting issues in the profile docs, and simplified line in the ylabel method of profile plot. Addresses issue #1298
Affected #:  2 files

diff -r b2b638026c53ad3c221da58cb5019d0e3bd36da7 -r 64cd3c2da8f267908b993e8568e8f6eaca53d903 doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -1090,11 +1090,11 @@
 
 .. python-script::
 
-  import yt
-  ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
-  ad = ds.all_data()
-  plot = yt.ProfilePlot(ad, "density", ["temperature", "velocity_x"],
-                   weight_field=None)
+   import yt
+   ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
+   ad = ds.all_data()
+   plot = yt.ProfilePlot(ad, "density", ["temperature", "velocity_x"],
+                    weight_field=None)
    plot.set_xlabel("Radius")
    plot.set_ylabel("x-velocity", "velocity in x direction")
    plot.save()

diff -r b2b638026c53ad3c221da58cb5019d0e3bd36da7 -r 64cd3c2da8f267908b993e8568e8f6eaca53d903 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -520,7 +520,7 @@
            The label to be placed on the y-axis
         """
         if field == "all":
-            for field in list(self.profiles[0].field_data.keys()):
+            for field in self.profiles[0].field_data:
                 self.y_title[field] = label
         else:
             field, = self.profiles[0].data_source._determine_fields([field])


https://bitbucket.org/yt_analysis/yt/commits/c443c9296f07/
Changeset:   c443c9296f07
User:        ngoldbaum
Date:        2018-02-22 14:45:14+00:00
Summary:     Merge pull request #1700 from AshKelly/profileplot_axis_labels

Added set_*label - command for ProfilePlot. Addresses Issue #1298
Affected #:  3 files

diff -r f4996439257b315b7e3982e21662d139f7855205 -r c443c9296f07bfd4dee0822b094ba3de8739f716 doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -1074,6 +1074,31 @@
    plot.set_log("x-velocity", False)
    plot.save()
 
+Setting axis labels
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The axis labels can be manipulated via the
+:meth:`~yt.visualization.profile_plotter.ProfilePlot.set_ylabel` and
+:meth:`~yt.visualization.profile_plotter.ProfilePlot.set_xlabel` functions.  The
+:meth:`~yt.visualization.profile_plotter.ProfilePlot.set_ylabel` function accepts a field name 
+and a string with the desired label. The :meth:`~yt.visualization.profile_plotter.ProfilePlot.set_xlabel`
+function just accepts the desired label and applies this to all of the plots. 
+
+In the following example we create a plot of the average x-velocity and density as a
+function of radius. The xlabel is set to "Radius", for all plots, and the ylabel is set to
+"velocity in x direction" for the x-velocity plot.
+
+.. python-script::
+
+   import yt
+   ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
+   ad = ds.all_data()
+   plot = yt.ProfilePlot(ad, "density", ["temperature", "velocity_x"],
+                    weight_field=None)
+   plot.set_xlabel("Radius")
+   plot.set_ylabel("x-velocity", "velocity in x direction")
+   plot.save()
+
 Altering Line Properties
 ~~~~~~~~~~~~~~~~~~~~~~~~
 

diff -r f4996439257b315b7e3982e21662d139f7855205 -r c443c9296f07bfd4dee0822b094ba3de8739f716 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -209,6 +209,7 @@
     Use set_line_property to change line properties of one or all profiles.
     
     """
+
     x_log = None
     y_log = None
     x_title = None
@@ -359,10 +360,13 @@
                 axes = self.axes[fname]
                 xscale, yscale = self._get_field_log(fname, profile)
                 xtitle, ytitle = self._get_field_title(fname, profile)
+
                 axes.set_xscale(xscale)
                 axes.set_yscale(yscale)
+
+                axes.set_ylabel(ytitle)
                 axes.set_xlabel(xtitle)
-                axes.set_ylabel(ytitle)
+
                 axes.set_ylim(*self.axes.ylim[fname])
                 axes.set_xlim(*self.axes.xlim)
                 if any(self.label):
@@ -383,6 +387,7 @@
                 field, = obj.profiles[0].data_source._determine_fields([field])
                 obj.y_log[field] = log
         obj.y_title = {}
+        obj.x_title = None
         obj.label = sanitize_label(labels, len(obj.profiles))
         if plot_specs is None:
             plot_specs = [dict() for p in obj.profiles]
@@ -501,6 +506,44 @@
                 raise KeyError("Field %s not in profile plot!" % (field))
         return self
 
+
+    @invalidate_plot
+    def set_ylabel(self, field, label):
+        """Sets a new ylabel for the specified fields
+
+        Parameters
+        ----------
+        field : string
+           The name of the field that is to be changed.
+
+        label : string
+           The label to be placed on the y-axis
+        """
+        if field == "all":
+            for field in self.profiles[0].field_data:
+                self.y_title[field] = label
+        else:
+            field, = self.profiles[0].data_source._determine_fields([field])
+            if field in self.profiles[0].field_data:
+                self.y_title[field] = label
+            else:
+                raise KeyError("Field %s not in profile plot!" % (field))
+
+        return self
+
+    @invalidate_plot
+    def set_xlabel(self, label):
+        """Sets a new xlabel for all profiles
+
+        Parameters
+        ----------
+        label : string
+           The label to be placed on the x-axis
+        """
+        self.x_title = label
+
+        return self
+
     @invalidate_plot
     def set_unit(self, field, unit):
         """Sets a new unit for the requested field

diff -r f4996439257b315b7e3982e21662d139f7855205 -r c443c9296f07bfd4dee0822b094ba3de8739f716 yt/visualization/tests/test_profile_plots.py
--- a/yt/visualization/tests/test_profile_plots.py
+++ b/yt/visualization/tests/test_profile_plots.py
@@ -169,4 +169,12 @@
     p2 = yt.PhasePlot(sp, ("enzo", "Density"), ("enzo", "Temperature"), "cell_mass")
     # make sure we can set the units using the tuple without erroring out
     p1.set_unit(("enzo", "Density"), "Msun/kpc**3")
-    p2.set_unit(("enzo", "Temperature"), "R")
\ No newline at end of file
+    p2.set_unit(("enzo", "Temperature"), "R")
+
+def test_set_labels():
+    ds = fake_random_ds(16)
+    ad = ds.all_data()
+    plot = yt.ProfilePlot(ad, "radius", ["velocity_x", "density"], weight_field=None)
+    # make sure we can set the labels without erroring out
+    plot.set_ylabel("all", "test ylabel")
+    plot.set_xlabel("test xlabel")
\ No newline at end of file

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the yt-svn mailing list