[yt-svn] commit/yt: MatthewTurk: Merged in chummels/yt/yt-3.0 (pull request #1023)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Jul 16 06:05:34 PDT 2014


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/fe6b0d8e6f9c/
Changeset:   fe6b0d8e6f9c
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-07-16 15:05:25
Summary:     Merged in chummels/yt/yt-3.0 (pull request #1023)

Fix the surface_plot recipe
Affected #:  3 files

diff -r 15df3bd5cf753b0c981ff75210c860eceda5b3dc -r fe6b0d8e6f9c4aaefccaa556dab34b11f8a1fd33 doc/source/cookbook/surface_plot.py
--- a/doc/source/cookbook/surface_plot.py
+++ b/doc/source/cookbook/surface_plot.py
@@ -1,6 +1,3 @@
-### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
-### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
-
 import yt
 import numpy as np
 from mpl_toolkits.mplot3d import Axes3D
@@ -28,8 +25,15 @@
 # Set the surface colors in the right scaling [0,1]
 p3dc.set_facecolors(colors[0,:,:]/255.)
 ax.add_collection(p3dc)
-ax.auto_scale_xyz(surface.vertices[0,:], surface.vertices[1,:], surface.vertices[2,:])
-ax.set_aspect(1.0)
+
+# Let's keep the axis ratio fixed in all directions by taking the maximum 
+# extent in one dimension and make it the bounds in all dimensions
+max_extent = (surface.vertices.max(axis=1) - surface.vertices.min(axis=1)).max()
+centers = (surface.vertices.max(axis=1) + surface.vertices.min(axis=1)) / 2
+bounds = np.zeros([3,2])
+bounds[:,0] = centers[:] - max_extent/2
+bounds[:,1] = centers[:] + max_extent/2
+ax.auto_scale_xyz(bounds[0,:], bounds[1,:], bounds[2,:])
 
 # Save the figure
 plt.savefig("%s_Surface.png" % ds)

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