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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Jul 18 09:38:26 PDT 2014


6 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/0fef65c48ab2/
Changeset:   0fef65c48ab2
Branch:      yt
User:        John Regan
Date:        2014-06-25 10:38:42
Summary:     Added a number of helper routines to PhasePlot
Affected #:  1 file

diff -r 43ef2f50b913f1ffbb8f65f736c14fdbb6acfa2f -r 0fef65c48ab2a2fb7aaee355179e5eb1d4119d58 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -517,11 +517,12 @@
                          weight_field=None)
     >>> plot.save()
 
-    >>> # Change plot properties.
+    >>> # Change plot properties. 
     >>> plot.set_cmap("CellMassMsun", "jet")
     >>> plot.set_zlim("CellMassMsun", 1e8, 1e13)
     >>> plot.set_title("CellMassMsun", "This is a phase plot")
-    
+    >>> N.B. The above callbacks will overwrite explicit 
+    >>> callbacks like set_xlim and hence should be done first.
     """
     x_log = None
     y_log = None
@@ -532,6 +533,7 @@
     _plot_valid = False
     _plot_type = 'Phase'
 
+
     def __init__(self, data_source, x_field, y_field, z_fields,
                  weight_field="CellMassMsun", x_bins=128, y_bins=128,
                  accumulation=False, fractional=False,
@@ -648,6 +650,138 @@
                     label.set_color(self._font_color)
         self._plot_valid = True
 
+
+
+    def set_xlim(self, xmin=None, xmax=None):
+        r"""
+        Sets the x-axis limits on the Phase plot. 
+        Defaults to None leaving the axis unchanged
+        Parameters
+        ----------
+        xmin: float
+              The minimum value on the x-axis
+        xmax: float
+              The maximum value on the x-axis
+
+        >>> plot.set_xlim(5e-21, 1e5)
+
+        """
+        for f, data in self.profile.field_data.items():
+            axes = None
+            if f in self.plots:
+                if self.plots[f].figure is not None:
+                    axes = self.plots[f].axes
+
+                self.plots[f].axes.set_xlim(xmin, xmax)
+
+    def set_ylim(self, ymin=None, ymax=None):
+        r"""
+        Sets the y-axis limits on the Phase plot. 
+        Defaults to None leaving the axis unchanged
+        Parameters
+        ----------
+        ymin: float
+              The minimum value on the y-axis
+        ymax: float
+              The maximum value on the y-axis
+
+        >>> plot.set_ylim(1e1, 1e5)
+
+        """
+       
+        for f, data in self.profile.field_data.items():
+            axes = None
+            if f in self.plots:
+                if self.plots[f].figure is not None:
+                    axes = self.plots[f].axes
+
+                self.plots[f].axes.set_ylim(ymin, ymax)
+
+    def set_xtitle(self, x_title=x_title, fontsize=18):
+        r"""
+        Allow the user to modify the X-axis title
+        Defaults to the global value. Fontsize defaults 
+        to 18.
+        
+        Parameters
+        ----------
+        x_title: str
+              The new string for the x-axis
+        fontsize: float
+              Fontsize for the x-axis title
+
+        >>>  plot.set_xtitle("H2I Number Density (cm$^{-3}$)")
+
+        """
+        for f in self.profile.field_data:
+            self.plots[f].axes.xaxis.set_label_text(x_title, fontsize=fontsize)
+
+    def set_ytitle(self, y_title=y_title, fontsize=18):
+        r"""
+        Allow the user to modify the Y-axis title
+        Defaults to the global value. Fontsize defaults 
+        to 18.
+        
+        Parameters
+        ----------
+        y_title: str
+              The new string for the y-axis
+        fontsize: float
+              Fontsize for the y-axis title
+
+        >>>  plot.set_ytitle("Temperature (K)")
+
+        """
+        for f in self.profile.field_data:
+            self.plots[f].axes.yaxis.set_label_text(y_title, fontsize=fontsize)
+
+    def set_ztitle(self, z_title=z_title, fontsize=18):
+        r"""
+        Allow the user to modify the Z-axis title
+        Defaults to the global value. Fontsize defaults 
+        to 18.
+        
+        Parameters
+        ----------
+        z_title: str
+              The new string for the z-axis
+        fontsize: float
+              Fontsize for the z-axis title
+
+        >>>  plot.set_ztitle("Enclosed Gas Mass ($M_{\odot}$)")
+
+        """
+        for f in self.profile.field_data:
+            self.plots[f].cax.yaxis.set_label_text(z_title, fontsize=fontsize)
+
+    def text(self, xpos=0.0, ypos=0.0, text_name="YT", fontsize=18, **kwargs):
+        r"""
+        Allow the user to insert text onto the plot
+        The x-position and y-position must be given as well as the text string. 
+        Fontsize defaults to 18.
+        
+        Parameters
+        ----------
+        xpos: float
+              Position on plot in x-coordinates
+        ypos: float
+              Position on plot in y-coordinates
+        text_name: str
+              The text to insert onto the plot
+        fontsize: float
+              Fontsize for the text (defaults to 18)
+
+        >>>  plot.text(1e-15, 5e4, "Hello YT")
+
+        """
+        for f, data in self.profile.field_data.items():
+            axes = None
+            if f in self.plots:
+                if self.plots[f].figure is not None:
+                    axes = self.plots[f].axes
+
+                self.plots[f].axes.text(xpos, ypos, text_name)
+
     def save(self, name=None, mpl_kwargs=None):
         r"""
         Saves a 2d profile plot.
@@ -662,18 +796,19 @@
         >>> plot.save(mpl_kwargs={'bbox_inches':'tight'})
         
         """
-
+        middle = ""
         if not self._plot_valid: self._setup_plots()
         if mpl_kwargs is None: mpl_kwargs = {}
         for f in self.profile.field_data:
-            middle = "2d-Profile_%s_%s_%s" % (self.profile.x_field, 
-                                              self.profile.y_field, f)
             if name is None:
+                middle = "2d-Profile_%s_%s_%s" % (self.profile.x_field, 
+                                                  self.profile.y_field, f)
+                
                 prefix = self.profile.pf
                 name = "%s.png" % prefix
             suffix = get_image_suffix(name)
             prefix = name[:name.rfind(suffix)]
-            fn = "%s_%s%s" % (prefix, middle, suffix)
+            fn = "%s%s%s" % (prefix, middle, suffix)
             if not suffix:
                 suffix = ".png"
             self.plots[f].save(fn, mpl_kwargs)


https://bitbucket.org/yt_analysis/yt/commits/b7558de772d3/
Changeset:   b7558de772d3
Branch:      yt
User:        John Regan
Date:        2014-07-03 07:45:16
Summary:     [xyz]label moved to plot_container.py. [xy]lim variables cached
Affected #:  3 files

diff -r 0fef65c48ab2a2fb7aaee355179e5eb1d4119d58 -r b7558de772d34892205cbfb690a5fe4f50ac02c8 doc/install_script.sh
--- a/doc/install_script.sh
+++ b/doc/install_script.sh
@@ -16,7 +16,7 @@
 
 DEST_SUFFIX="yt-`uname -m`"
 DEST_DIR="`pwd`/${DEST_SUFFIX/ /}"   # Installation location
-BRANCH="yt" # This is the branch to which we will forcibly update.
+BRANCH="yt-dev" # This is the branch to which we will forcibly update.
 
 if [ ${REINST_YT} ] && [ ${REINST_YT} -eq 1 ] && [ -n ${YT_DEST} ]
 then

diff -r 0fef65c48ab2a2fb7aaee355179e5eb1d4119d58 -r b7558de772d34892205cbfb690a5fe4f50ac02c8 yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -109,6 +109,9 @@
         font_path = matplotlib.get_data_path() + '/fonts/ttf/STIXGeneral.ttf'
         self._font_properties = FontProperties(size=fontsize, fname=font_path)
         self._font_color = None
+        self._xlabel = None
+        self._ylabel = None
+        self._colorbarlabel = None
 
     @invalidate_plot
     def set_log(self, field, log):
@@ -475,3 +478,67 @@
             img = base64.b64encode(self.plots[field]._repr_png_())
             ret += '<img src="data:image/png;base64,%s"><br>' % img
         return ret
+
+    def set_xlabel(self, x_title, fontsize=18):
+        r"""
+        Allow the user to modify the X-axis title
+        Defaults to the global value. Fontsize defaults 
+        to 18.
+        
+        Parameters
+        ----------
+        x_title: str
+              The new string for the x-axis. This is a required argument. 
+
+        fontsize: float
+              Fontsize for the x-axis title
+
+        >>>  plot.set_xtitle("H2I Number Density (cm$^{-3}$)")
+
+        """
+        for f in self.plots:
+            self.plots[f].axes.xaxis.set_label_text(x_title, fontsize=fontsize)
+        self._xlabel = x_title
+
+    def set_ylabel(self, y_title, fontsize=18):
+        r"""
+        Allow the user to modify the Y-axis title
+        Defaults to the global value. Fontsize defaults 
+        to 18.
+        
+        Parameters
+        ----------
+        y_title: str
+              The new string for the y-axis. This is a required argument. 
+        fontsize: float
+              Fontsize for the y-axis title
+
+        >>>  plot.set_ytitle("Temperature (K)")
+
+        """
+        for f in self.plots:
+            self.plots[f].axes.yaxis.set_label_text(y_title, fontsize=fontsize)
+        self._ylabel = y_title
+
+    def set_colorbar_label(self, z_title, fontsize=18):
+        r"""
+        Allow the user to modify the Z-axis title
+        Defaults to the global value. Fontsize defaults 
+        to 18.
+        
+        Parameters
+        ----------
+        z_title: str
+              The new string for the colorbar. This is a required argument.
+        fontsize: float
+              Fontsize for the z-axis title
+
+        >>>  plot.set_ztitle("Enclosed Gas Mass ($M_{\odot}$)")
+
+        """
+        for f in self.plots:
+            self.plots[f].cax.yaxis.set_label_text(z_title, fontsize=fontsize)
+        self._colorbarlabel = z_title
+
+    def _get_axes_labels(self):
+        return(self._xlabel, self._ylabel, self._colorbarlabel)

diff -r 0fef65c48ab2a2fb7aaee355179e5eb1d4119d58 -r b7558de772d34892205cbfb690a5fe4f50ac02c8 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -542,6 +542,14 @@
         self.z_log = {}
         self.z_title = {}
         self._initfinished = False
+        self._xlimits = [0,0]
+        self._ylimits = [0,0]
+        self._setxlims = False
+        self._setylims = False
+        self._plottext = ""
+        self._textxpos = 0.0
+        self._textypos = 0.0
+
 
         if profile is None:
             profile = create_profile(data_source,
@@ -564,10 +572,11 @@
         xfi = pf.field_info[field_x]
         yfi = pf.field_info[field_y]
         zfi = pf.field_info[field_z]
+       
         x_title = self.x_title or self._get_field_label(field_x, xfi)
         y_title = self.y_title or self._get_field_label(field_y, yfi)
         z_title = self.z_title.get(field_z, None) or \
-                    self._get_field_label(field_z, zfi)
+            self._get_field_label(field_z, zfi)
         return (x_title, y_title, z_title)
 
     def _get_field_label(self, field, field_info):
@@ -614,7 +623,16 @@
 
             size = (self.figure_size, self.figure_size)
             x_scale, y_scale, z_scale = self._get_field_log(f, self.profile)
+            x_label, y_label, z_label = self._get_axes_labels()
             x_title, y_title, z_title = self._get_field_title(f, self.profile)
+            #If the labels are set they take precedence
+            if x_label != None:
+                x_title = x_label
+            if y_label != None:
+                y_title = y_label
+            if z_label != None:
+                z_title = z_label
+
             if f in self.plots:
                 zlim = [self.plots[f].zmin, self.plots[f].zmax]
             else:
@@ -629,16 +647,24 @@
                                          x_scale, y_scale, z_scale,
                                          self._colormaps[f], zlim, size, fp.get_size(),
                                          fig, axes, cax)
+
             self.plots[f].axes.xaxis.set_label_text(x_title)
             self.plots[f].axes.yaxis.set_label_text(y_title)
             self.plots[f].cax.yaxis.set_label_text(z_title)
+            if(self._setxlims == True):
+                self.plots[f].axes.set_xlim(self._xlimits[0], self._xlimits[1])
+            if(self._setylims == True):
+                self.plots[f].axes.set_ylim(self._ylimits[0], self._ylimits[1])
+           
+            self.plots[f].axes.text(self._textxpos, self._textypos, self._plottext,
+                                    fontproperties=self._font_properties)
             if z_scale == "log":
                 self._field_transform[f] = log_transform
             else:
                 self._field_transform[f] = linear_transform
             if f in self.plot_title:
                 self.plots[f].axes.set_title(self.plot_title[f])
-
+               
             if self._font_color is not None:
                 ax = self.plots[f].axes
                 cbax = self.plots[f].cb.ax
@@ -651,7 +677,6 @@
         self._plot_valid = True
 
 
-
     def set_xlim(self, xmin=None, xmax=None):
         r"""
         Sets the x-axis limits on the Phase plot. 
@@ -664,8 +689,8 @@
               The maximum value on the x-axis
 
         >>> plot.set_xlim(5e-21, 1e5)
+        """
 
-        """
         for f, data in self.profile.field_data.items():
             axes = None
             if f in self.plots:
@@ -673,6 +698,9 @@
                     axes = self.plots[f].axes
 
                 self.plots[f].axes.set_xlim(xmin, xmax)
+        self._setxlims = True
+        self._xlimits[0] = xmin
+        self._xlimits[1] = xmax
 
     def set_ylim(self, ymin=None, ymax=None):
         r"""
@@ -696,65 +724,11 @@
                     axes = self.plots[f].axes
 
                 self.plots[f].axes.set_ylim(ymin, ymax)
-
-    def set_xtitle(self, x_title=x_title, fontsize=18):
-        r"""
-        Allow the user to modify the X-axis title
-        Defaults to the global value. Fontsize defaults 
-        to 18.
-        
-        Parameters
-        ----------
-        x_title: str
-              The new string for the x-axis
-        fontsize: float
-              Fontsize for the x-axis title
-
-        >>>  plot.set_xtitle("H2I Number Density (cm$^{-3}$)")
-
-        """
-        for f in self.profile.field_data:
-            self.plots[f].axes.xaxis.set_label_text(x_title, fontsize=fontsize)
-
-    def set_ytitle(self, y_title=y_title, fontsize=18):
-        r"""
-        Allow the user to modify the Y-axis title
-        Defaults to the global value. Fontsize defaults 
-        to 18.
-        
-        Parameters
-        ----------
-        y_title: str
-              The new string for the y-axis
-        fontsize: float
-              Fontsize for the y-axis title
-
-        >>>  plot.set_ytitle("Temperature (K)")
-
-        """
-        for f in self.profile.field_data:
-            self.plots[f].axes.yaxis.set_label_text(y_title, fontsize=fontsize)
-
-    def set_ztitle(self, z_title=z_title, fontsize=18):
-        r"""
-        Allow the user to modify the Z-axis title
-        Defaults to the global value. Fontsize defaults 
-        to 18.
-        
-        Parameters
-        ----------
-        z_title: str
-              The new string for the z-axis
-        fontsize: float
-              Fontsize for the z-axis title
-
-        >>>  plot.set_ztitle("Enclosed Gas Mass ($M_{\odot}$)")
-
-        """
-        for f in self.profile.field_data:
-            self.plots[f].cax.yaxis.set_label_text(z_title, fontsize=fontsize)
-
-    def text(self, xpos=0.0, ypos=0.0, text_name="YT", fontsize=18, **kwargs):
+        self._setylims = True
+        self._ylimits[0] = ymin
+        self._ylimits[1] = ymax
+   
+    def add_text(self, text_str, xpos, ypos, fontsize=18, **kwargs):
         r"""
         Allow the user to insert text onto the plot
         The x-position and y-position must be given as well as the text string. 
@@ -762,12 +736,12 @@
         
         Parameters
         ----------
+        text_str: str
+              The text to insert onto the plot. Required argument. 
         xpos: float
-              Position on plot in x-coordinates
+              Position on plot in x-coordinates. Required argument. 
         ypos: float
-              Position on plot in y-coordinates
-        text_name: str
-              The text to insert onto the plot
+              Position on plot in y-coordinates. Required argument. 
         fontsize: float
               Fontsize for the text (defaults to 18)
 
@@ -779,8 +753,11 @@
             if f in self.plots:
                 if self.plots[f].figure is not None:
                     axes = self.plots[f].axes
-
-                self.plots[f].axes.text(xpos, ypos, text_name)
+                    self.plots[f].axes.text(xpos, ypos, text_str,
+                                            fontproperties=self._font_properties)
+        self._plottext = text_str
+        self._textxpos = xpos
+        self._textypos = ypos
 
     def save(self, name=None, mpl_kwargs=None):
         r"""


https://bitbucket.org/yt_analysis/yt/commits/7694ea4d99a0/
Changeset:   7694ea4d99a0
Branch:      yt
User:        John Regan
Date:        2014-07-03 08:31:23
Summary:     Undoing install_script change, removing comment and changing != to is not
Affected #:  2 files

diff -r b7558de772d34892205cbfb690a5fe4f50ac02c8 -r 7694ea4d99a0fd1c59559746caffe76742f34dce doc/install_script.sh
--- a/doc/install_script.sh
+++ b/doc/install_script.sh
@@ -16,7 +16,7 @@
 
 DEST_SUFFIX="yt-`uname -m`"
 DEST_DIR="`pwd`/${DEST_SUFFIX/ /}"   # Installation location
-BRANCH="yt-dev" # This is the branch to which we will forcibly update.
+BRANCH="yt" # This is the branch to which we will forcibly update.
 
 if [ ${REINST_YT} ] && [ ${REINST_YT} -eq 1 ] && [ -n ${YT_DEST} ]
 then

diff -r b7558de772d34892205cbfb690a5fe4f50ac02c8 -r 7694ea4d99a0fd1c59559746caffe76742f34dce yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -521,8 +521,6 @@
     >>> plot.set_cmap("CellMassMsun", "jet")
     >>> plot.set_zlim("CellMassMsun", 1e8, 1e13)
     >>> plot.set_title("CellMassMsun", "This is a phase plot")
-    >>> N.B. The above callbacks will overwrite explicit 
-    >>> callbacks like set_xlim and hence should be done first.
     """
     x_log = None
     y_log = None
@@ -626,11 +624,11 @@
             x_label, y_label, z_label = self._get_axes_labels()
             x_title, y_title, z_title = self._get_field_title(f, self.profile)
             #If the labels are set they take precedence
-            if x_label != None:
+            if x_label is not None:
                 x_title = x_label
-            if y_label != None:
+            if y_label is not None:
                 y_title = y_label
-            if z_label != None:
+            if z_label is not None:
                 z_title = z_label
 
             if f in self.plots:


https://bitbucket.org/yt_analysis/yt/commits/c1a12ec48f5a/
Changeset:   c1a12ec48f5a
Branch:      yt
User:        John Regan
Date:        2014-07-03 15:14:08
Summary:     Reverting changes to save function
Affected #:  1 file

diff -r 7694ea4d99a0fd1c59559746caffe76742f34dce -r c1a12ec48f5a5aee12506011fdb7b7aad247fd42 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -771,19 +771,18 @@
         >>> plot.save(mpl_kwargs={'bbox_inches':'tight'})
         
         """
-        middle = ""
+
         if not self._plot_valid: self._setup_plots()
         if mpl_kwargs is None: mpl_kwargs = {}
         for f in self.profile.field_data:
+            middle = "2d-Profile_%s_%s_%s" % (self.profile.x_field, 
+                                              self.profile.y_field, f)
             if name is None:
-                middle = "2d-Profile_%s_%s_%s" % (self.profile.x_field, 
-                                                  self.profile.y_field, f)
-                
                 prefix = self.profile.pf
                 name = "%s.png" % prefix
             suffix = get_image_suffix(name)
             prefix = name[:name.rfind(suffix)]
-            fn = "%s%s%s" % (prefix, middle, suffix)
+            fn = "%s_%s%s" % (prefix, middle, suffix)
             if not suffix:
                 suffix = ".png"
             self.plots[f].save(fn, mpl_kwargs)


https://bitbucket.org/yt_analysis/yt/commits/1f4a095e4e93/
Changeset:   1f4a095e4e93
Branch:      yt
User:        John Regan
Date:        2014-07-18 08:22:44
Summary:     Small update to comment in add_text function
Affected #:  1 file

diff -r c1a12ec48f5a5aee12506011fdb7b7aad247fd42 -r 1f4a095e4e9322cc7426ea06029245dbd1e6ef73 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -730,6 +730,7 @@
         r"""
         Allow the user to insert text onto the plot
         The x-position and y-position must be given as well as the text string. 
+        Add text_str plot at location x, y, data coordinates (see example below).
         Fontsize defaults to 18.
         
         Parameters


https://bitbucket.org/yt_analysis/yt/commits/ad16dc5a05fd/
Changeset:   ad16dc5a05fd
Branch:      yt
User:        ngoldbaum
Date:        2014-07-18 18:38:20
Summary:     Merged in john_regan/yt-phase-dev (pull request #980)

Added a number of helper routines to PhasePlot
Affected #:  3 files

diff -r e89295c7393d410f8d3f1f2868d1fbad428cd654 -r ad16dc5a05fdaf6cd84949869b4d847791b4cddc yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -109,6 +109,9 @@
         font_path = matplotlib.get_data_path() + '/fonts/ttf/STIXGeneral.ttf'
         self._font_properties = FontProperties(size=fontsize, fname=font_path)
         self._font_color = None
+        self._xlabel = None
+        self._ylabel = None
+        self._colorbarlabel = None
 
     @invalidate_plot
     def set_log(self, field, log):
@@ -475,3 +478,67 @@
             img = base64.b64encode(self.plots[field]._repr_png_())
             ret += '<img src="data:image/png;base64,%s"><br>' % img
         return ret
+
+    def set_xlabel(self, x_title, fontsize=18):
+        r"""
+        Allow the user to modify the X-axis title
+        Defaults to the global value. Fontsize defaults 
+        to 18.
+        
+        Parameters
+        ----------
+        x_title: str
+              The new string for the x-axis. This is a required argument. 
+
+        fontsize: float
+              Fontsize for the x-axis title
+
+        >>>  plot.set_xtitle("H2I Number Density (cm$^{-3}$)")
+
+        """
+        for f in self.plots:
+            self.plots[f].axes.xaxis.set_label_text(x_title, fontsize=fontsize)
+        self._xlabel = x_title
+
+    def set_ylabel(self, y_title, fontsize=18):
+        r"""
+        Allow the user to modify the Y-axis title
+        Defaults to the global value. Fontsize defaults 
+        to 18.
+        
+        Parameters
+        ----------
+        y_title: str
+              The new string for the y-axis. This is a required argument. 
+        fontsize: float
+              Fontsize for the y-axis title
+
+        >>>  plot.set_ytitle("Temperature (K)")
+
+        """
+        for f in self.plots:
+            self.plots[f].axes.yaxis.set_label_text(y_title, fontsize=fontsize)
+        self._ylabel = y_title
+
+    def set_colorbar_label(self, z_title, fontsize=18):
+        r"""
+        Allow the user to modify the Z-axis title
+        Defaults to the global value. Fontsize defaults 
+        to 18.
+        
+        Parameters
+        ----------
+        z_title: str
+              The new string for the colorbar. This is a required argument.
+        fontsize: float
+              Fontsize for the z-axis title
+
+        >>>  plot.set_ztitle("Enclosed Gas Mass ($M_{\odot}$)")
+
+        """
+        for f in self.plots:
+            self.plots[f].cax.yaxis.set_label_text(z_title, fontsize=fontsize)
+        self._colorbarlabel = z_title
+
+    def _get_axes_labels(self):
+        return(self._xlabel, self._ylabel, self._colorbarlabel)

diff -r e89295c7393d410f8d3f1f2868d1fbad428cd654 -r ad16dc5a05fdaf6cd84949869b4d847791b4cddc yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -517,11 +517,10 @@
                          weight_field=None)
     >>> plot.save()
 
-    >>> # Change plot properties.
+    >>> # Change plot properties. 
     >>> plot.set_cmap("CellMassMsun", "jet")
     >>> plot.set_zlim("CellMassMsun", 1e8, 1e13)
     >>> plot.set_title("CellMassMsun", "This is a phase plot")
-    
     """
     x_log = None
     y_log = None
@@ -532,6 +531,7 @@
     _plot_valid = False
     _plot_type = 'Phase'
 
+
     def __init__(self, data_source, x_field, y_field, z_fields,
                  weight_field="CellMassMsun", x_bins=128, y_bins=128,
                  accumulation=False, fractional=False,
@@ -540,6 +540,14 @@
         self.z_log = {}
         self.z_title = {}
         self._initfinished = False
+        self._xlimits = [0,0]
+        self._ylimits = [0,0]
+        self._setxlims = False
+        self._setylims = False
+        self._plottext = ""
+        self._textxpos = 0.0
+        self._textypos = 0.0
+
 
         if profile is None:
             profile = create_profile(data_source,
@@ -562,10 +570,11 @@
         xfi = pf.field_info[field_x]
         yfi = pf.field_info[field_y]
         zfi = pf.field_info[field_z]
+       
         x_title = self.x_title or self._get_field_label(field_x, xfi)
         y_title = self.y_title or self._get_field_label(field_y, yfi)
         z_title = self.z_title.get(field_z, None) or \
-                    self._get_field_label(field_z, zfi)
+            self._get_field_label(field_z, zfi)
         return (x_title, y_title, z_title)
 
     def _get_field_label(self, field, field_info):
@@ -612,7 +621,16 @@
 
             size = (self.figure_size, self.figure_size)
             x_scale, y_scale, z_scale = self._get_field_log(f, self.profile)
+            x_label, y_label, z_label = self._get_axes_labels()
             x_title, y_title, z_title = self._get_field_title(f, self.profile)
+            #If the labels are set they take precedence
+            if x_label is not None:
+                x_title = x_label
+            if y_label is not None:
+                y_title = y_label
+            if z_label is not None:
+                z_title = z_label
+
             if f in self.plots:
                 zlim = [self.plots[f].zmin, self.plots[f].zmax]
             else:
@@ -627,16 +645,24 @@
                                          x_scale, y_scale, z_scale,
                                          self._colormaps[f], zlim, size, fp.get_size(),
                                          fig, axes, cax)
+
             self.plots[f].axes.xaxis.set_label_text(x_title)
             self.plots[f].axes.yaxis.set_label_text(y_title)
             self.plots[f].cax.yaxis.set_label_text(z_title)
+            if(self._setxlims == True):
+                self.plots[f].axes.set_xlim(self._xlimits[0], self._xlimits[1])
+            if(self._setylims == True):
+                self.plots[f].axes.set_ylim(self._ylimits[0], self._ylimits[1])
+           
+            self.plots[f].axes.text(self._textxpos, self._textypos, self._plottext,
+                                    fontproperties=self._font_properties)
             if z_scale == "log":
                 self._field_transform[f] = log_transform
             else:
                 self._field_transform[f] = linear_transform
             if f in self.plot_title:
                 self.plots[f].axes.set_title(self.plot_title[f])
-
+               
             if self._font_color is not None:
                 ax = self.plots[f].axes
                 cbax = self.plots[f].cb.ax
@@ -648,6 +674,90 @@
                     label.set_color(self._font_color)
         self._plot_valid = True
 
+
+    def set_xlim(self, xmin=None, xmax=None):
+        r"""
+        Sets the x-axis limits on the Phase plot. 
+        Defaults to None leaving the axis unchanged
+        Parameters
+        ----------
+        xmin: float
+              The minimum value on the x-axis
+        xmax: float
+              The maximum value on the x-axis
+
+        >>> plot.set_xlim(5e-21, 1e5)
+        """
+
+        for f, data in self.profile.field_data.items():
+            axes = None
+            if f in self.plots:
+                if self.plots[f].figure is not None:
+                    axes = self.plots[f].axes
+
+                self.plots[f].axes.set_xlim(xmin, xmax)
+        self._setxlims = True
+        self._xlimits[0] = xmin
+        self._xlimits[1] = xmax
+
+    def set_ylim(self, ymin=None, ymax=None):
+        r"""
+        Sets the y-axis limits on the Phase plot. 
+        Defaults to None leaving the axis unchanged
+        Parameters
+        ----------
+        ymin: float
+              The minimum value on the y-axis
+        ymax: float
+              The maximum value on the y-axis
+
+        >>> plot.set_ylim(1e1, 1e5)
+
+        """
+       
+        for f, data in self.profile.field_data.items():
+            axes = None
+            if f in self.plots:
+                if self.plots[f].figure is not None:
+                    axes = self.plots[f].axes
+
+                self.plots[f].axes.set_ylim(ymin, ymax)
+        self._setylims = True
+        self._ylimits[0] = ymin
+        self._ylimits[1] = ymax
+   
+    def add_text(self, text_str, xpos, ypos, fontsize=18, **kwargs):
+        r"""
+        Allow the user to insert text onto the plot
+        The x-position and y-position must be given as well as the text string. 
+        Add text_str plot at location x, y, data coordinates (see example below).
+        Fontsize defaults to 18.
+        
+        Parameters
+        ----------
+        text_str: str
+              The text to insert onto the plot. Required argument. 
+        xpos: float
+              Position on plot in x-coordinates. Required argument. 
+        ypos: float
+              Position on plot in y-coordinates. Required argument. 
+        fontsize: float
+              Fontsize for the text (defaults to 18)
+
+        >>>  plot.text(1e-15, 5e4, "Hello YT")
+
+        """
+        for f, data in self.profile.field_data.items():
+            axes = None
+            if f in self.plots:
+                if self.plots[f].figure is not None:
+                    axes = self.plots[f].axes
+                    self.plots[f].axes.text(xpos, ypos, text_str,
+                                            fontproperties=self._font_properties)
+        self._plottext = text_str
+        self._textxpos = xpos
+        self._textypos = ypos
+
     def save(self, name=None, mpl_kwargs=None):
         r"""
         Saves a 2d profile plot.

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