[yt-svn] commit/yt: mzingale: Merged in ngoldbaum/yt/yt-3.0 (pull request #1093)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Jul 29 12:57:40 PDT 2014


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/db184f28bbac/
Changeset:   db184f28bbac
Branch:      yt-3.0
User:        mzingale
Date:        2014-07-29 21:57:32
Summary:     Merged in ngoldbaum/yt/yt-3.0 (pull request #1093)

Updating the plotting docs per Aaron Smith's suggestions.
Affected #:  1 file

diff -r feb0e7bd1aea157ba3ddc881358db4d71070ff19 -r db184f28bbac06e15f81292ec306ed0b7f102a69 doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -59,8 +59,8 @@
 
 .. code-block:: python
 
-   >>> slc = yt.SlicePlot(ds, 'z', 'density')
-   >>> slc.save()
+    slc = yt.SlicePlot(ds, 'z', 'density')
+    slc.save()
 
 These two commands will create a slice object and store it in a variable we've
 called ``slc``.  Since this plot is aligned with the simulation coordinate
@@ -72,7 +72,7 @@
 
 .. code-block:: python
    
-   >>> yt.SlicePlot(ds, 'z', 'density').save()
+    yt.SlicePlot(ds, 'z', 'density').save()
 
 It's nice to keep the slice object around if you want to modify the plot.  By
 default, the plot width will be set to the size of the simulation box.  To zoom
@@ -81,9 +81,9 @@
 
 .. code-block:: python
 
-   >>> slc = yt.SlicePlot(ds, 'z', 'density')
-   >>> slc.zoom(10)
-   >>> slc.save('zoom')
+    slc = yt.SlicePlot(ds, 'z', 'density')
+    slc.zoom(10)
+    slc.save('zoom')
 
 This will save a new plot to disk with a different filename - prepended with
 'zoom' instead of the name of the dataset. If you want to set the width
@@ -93,10 +93,10 @@
 
 .. code-block:: python
 
-   >>> from yt.units import kpc
-   >>> slc = yt.SlicePlot(ds, 'z', 'density')
-   >>> slc.set_width(10*kpc)
-   >>> slc.save('10kpc')
+    from yt.units import kpc
+    slc = yt.SlicePlot(ds, 'z', 'density')
+    slc.set_width(10*kpc)
+    slc.save('10kpc')
 
 The plot width can be specified independently along the x and y direction by
 passing a tuple of widths.  An individual width can also be represented using a
@@ -105,18 +105,18 @@
 
 .. code-block:: python
 
-   >>> from yt.units import kpc
-   >>> slc.set_width(200*kpc)
-   >>> slc.set_width((200, 'kpc'))
-   >>> slc.set_width((200*kpc, 200*kpc))
+    from yt.units import kpc
+    slc.set_width(200*kpc)
+    slc.set_width((200, 'kpc'))
+    slc.set_width((200*kpc, 200*kpc))
 
 The ``SlicePlot`` also optionally accepts the coordinate to center the plot on
 and the width of the plot:
 
 .. code-block:: python
 
-   >>> yt.SlicePlot(ds, 'z', 'density', center=[0.2, 0.3, 0.8],
-   ...              width = (10,'kpc')).save()
+    yt.SlicePlot(ds, 'z', 'density', center=[0.2, 0.3, 0.8],
+                 width = (10,'kpc')).save()
 
 The plot center is relative to the simulation coordinate system.  If supplied
 without units, the center is assumed by in code units.  Optionally, you can
@@ -229,12 +229,12 @@
 Off Axis Projection Plots
 ~~~~~~~~~~~~~~~~~~~~~~~~~
 
-Off axis projection plots .  Internally, off axis projections are
-created using :ref:`the-camera-interface` by applying the
+Internally, off axis projections are created using :ref:`the-camera-interface`
+by applying the
 :class:`~yt.visualization.volume_rendering.transfer_functions.ProjectionTransferFunction`.
-In this use case, the volume renderer casts a set of plane
-parallel rays, one for each pixel in the image.  The data values
-along each ray are summed, creating the final image buffer.
+In this use case, the volume renderer casts a set of plane parallel rays, one
+for each pixel in the image.  The data values along each ray are summed,
+creating the final image buffer.
 
 .. _off-axis-projection-function:
 
@@ -443,7 +443,8 @@
 will plot the density field in a 10 kiloparsec slice through the
 z-axis centered on the highest density point in the simulation domain.
 Before saving the plot, the script annotates it with the grid
-boundaries, which are drawn as thick black lines by default.
+boundaries, which are drawn as lines in the plot, with colors going
+from black to white depending on the AMR level of the grid.
 
 Annotations are described in :ref:`callbacks`.
 
@@ -484,8 +485,8 @@
 
 .. code-block:: python
 
-   >>> slc = SlicePlot(ds, 2, ['density', 'temperature']
-   >>> dens_plot = slc.plots['density']
+    slc = SlicePlot(ds, 2, ['density', 'temperature']
+    dens_plot = slc.plots['density']
 
 In this example ``dens_plot`` is an instance of
 :class:`~yt.visualization.plot_window.WindowPlotMPL`, an object that wraps the
@@ -493,9 +494,9 @@
 
 .. code-block:: python
 
-   >>> figure = dens_plot.figure
-   >>> axes = dens_plot.axes
-   >>> colorbar_axes = dens_plot.cax
+    figure = dens_plot.figure
+    axes = dens_plot.axes
+    colorbar_axes = dens_plot.cax
 
 These are the :ref:`matplotlib:figure`, and :ref:`matplotlib:axes` objects
 that control the actual drawing of the plot.  Arbitrary plot customizations
@@ -548,14 +549,26 @@
                          weight_field=None)
    plot.save()
 
-Note that because we have specified the weighting field to be none, it operates
-the profile plot will display the accumulated cell mass as a function of
-temperature rather than the average.  We can also accumulate along the x-axis by
-setting the **accumulation** keyword argument to True, which is useful for plots
-of enclosed mass.
+Note that because we have specified the weighting field to be ``None``, the
+profile plot will display the accumulated cell mass as a function of temperature
+rather than the average. Also note the use of a ``(value, unit)`` tuple. These
+can be used interchangably with units explicitly imported from ``yt.units`` when
+creating yt plots.
 
-Also note the use of a ``(value, unit)`` tuple. These can be used interchangably
-with units explicitly imported from ``yt.units``.
+We can also accumulate along the bin field of a ``ProfilePlot`` (the bin field
+is the x-axis in a ``ProfilePlot``, in the last example the bin field is
+``Temperature``) by setting the ``accumulation`` keyword argument to ``True``.
+The following example uses ``weight_field = None`` and ``accumulation = True`` to
+generate a plot of the enclosed mass in a sphere:
+
+.. python-script::
+
+   import yt
+   ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
+   my_sphere = ds.sphere([0.5, 0.5, 0.5], (100, "kpc"))
+   plot = yt.ProfilePlot(my_sphere, "radius", ["cell_mass"],
+                         weight_field=None, accumulation=True)
+   plot.save()
 
 You can also access the data generated by profiles directly, which can be
 useful for overplotting average quantities on top of phase plots, or for
@@ -570,9 +583,9 @@
                       weight_field=None)
    profile = plot.profiles[0]
    # print the bin field, in this case temperature
-   print plot.profiles[-1].x
+   print profile.x
    # print the profiled cell_mass field
-   print plot.profiles[-1]["cell_mass"]
+   print profile['cell_mass']
 
 Other options, such as the number of bins, are also configurable. See the
 documentation for :class:`~yt.visualization.profile_plotter.ProfilePlot` for
@@ -717,15 +730,15 @@
 
 .. code-block:: python
 
-   >>> plot.set_line_property("linestyle", "--")
+    plot.set_line_property("linestyle", "--")
 
 With no additional arguments, all of the lines plotted will be altered.  To 
 change the property of a single line, give also the index of the profile.
 
 .. code-block:: python
 
-   >>> # change only the first line
-   >>> plot.set_line_property("linestyle", "--", 0)
+    # change only the first line
+    plot.set_line_property("linestyle", "--", 0)
 
 .. _how-to-make-2d-profiles:
 
@@ -882,12 +895,12 @@
 
 .. code-block:: python
 
-   >>> import yt.visualization.eps_writer as eps
-   >>> slc = yt.SlicePlot(ds, 'z', 'density')
-   >>> slc.set_width(25, 'kpc')
-   >>> eps_fig = eps.single_plot(slc)
-   >>> eps_fig.save_fig('zoom', format='eps')
-   >>> eps_fig.save_fig('zoom-pdf', format='pdf')
+    import yt.visualization.eps_writer as eps
+    slc = yt.SlicePlot(ds, 'z', 'density')
+    slc.set_width(25, 'kpc')
+    eps_fig = eps.single_plot(slc)
+    eps_fig.save_fig('zoom', format='eps')
+    eps_fig.save_fig('zoom-pdf', format='pdf')
 
 The ``eps_fig`` object exposes all of the low-level functionality of
 ``PyX`` for further customization (see the `PyX documentation
@@ -896,8 +909,8 @@
 
 .. code-block:: python
 
-   >>> eps_fig.circle(radius=0.2, loc=(0.5,0.5))
-   >>> eps_fig.sav_fig('zoom-circle', format='eps')
+    eps_fig.circle(radius=0.2, loc=(0.5,0.5))
+    eps_fig.sav_fig('zoom-circle', format='eps')
 
 with a radius of 0.2 at a center of (0.5, 0.5), both of which are in
 units of the figure's field of view.  The
@@ -907,15 +920,15 @@
 
 .. code-block:: python
 
-   >>> import yt
-   >>> import yt.visualization.eps_writer as eps
-   >>>
-   >>> slc = yt.SlicePlot(ds, 'z', ['density', 'temperature', 'Pressure',
-                          'VelocityMagnitude'])
-   >>> slc.set_width(25, 'kpc')
-   >>> eps_fig = eps.multiplot_yt(2, 2, slc, bare_axes=True)
-   >>> eps_fig.scale_line(0.2, '5 kpc')
-   >>> eps_fig.save_fig('multi', format='eps')
+    import yt
+    import yt.visualization.eps_writer as eps
+   
+    slc = yt.SlicePlot(ds, 'z', ['density', 'temperature', 'pressure',
+                       'velocity_magnitude'])
+    slc.set_width(25, 'kpc')
+    eps_fig = eps.multiplot_yt(2, 2, slc, bare_axes=True)
+    eps_fig.scale_line(0.2, '5 kpc')
+    eps_fig.save_fig('multi', format='eps')
 
 will produce a 2x2 panel figure with a scale bar indicating 5 kpc.
 The routine will try its best to place the colorbars in the optimal

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