SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

You can subscribe to this list here.

2007 Jan
Feb
Mar
Apr
May
Jun
Jul
(115)
Aug
(120)
Sep
(137)
Oct
(170)
Nov
(461)
Dec
(263)
2008 Jan
(120)
Feb
(74)
Mar
(35)
Apr
(74)
May
(245)
Jun
(356)
Jul
(240)
Aug
(115)
Sep
(78)
Oct
(225)
Nov
(98)
Dec
(271)
2009 Jan
(132)
Feb
(84)
Mar
(74)
Apr
(56)
May
(90)
Jun
(79)
Jul
(83)
Aug
(296)
Sep
(214)
Oct
(76)
Nov
(82)
Dec
(66)
2010 Jan
(46)
Feb
(58)
Mar
(51)
Apr
(77)
May
(58)
Jun
(126)
Jul
(128)
Aug
(64)
Sep
(50)
Oct
(44)
Nov
(48)
Dec
(54)
2011 Jan
(68)
Feb
(52)
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S




1
(5)
2
(1)
3
(1)
4
(1)
5
(5)
6
(7)
7
(2)
8
9
(6)
10
11
(9)
12
(8)
13
(2)
14
(3)
15
16
(4)
17
(1)
18
19
(4)
20
21
(5)
22
(2)
23
(4)
24
25
(3)
26
(2)
27
28
29
(1)
30
31

Showing 1 results of 1

From: <lee...@us...> - 2009年10月03日 18:11:19
Revision: 7842
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7842&view=rev
Author: leejjoon
Date: 2009年10月03日 18:11:09 +0000 (2009年10月03日)
Log Message:
-----------
add PathPatch3d in mplot3d.art3d
Modified Paths:
--------------
 trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py
Added Paths:
-----------
 trunk/matplotlib/examples/mplot3d/pathpatch3d_demo.py
Added: trunk/matplotlib/examples/mplot3d/pathpatch3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/pathpatch3d_demo.py	 (rev 0)
+++ trunk/matplotlib/examples/mplot3d/pathpatch3d_demo.py	2009年10月03日 18:11:09 UTC (rev 7842)
@@ -0,0 +1,52 @@
+import matplotlib.pyplot as plt
+from matplotlib.patches import Circle, PathPatch
+from mpl_toolkits.mplot3d import Axes3D
+import mpl_toolkits.mplot3d.art3d as art3d
+from matplotlib.text import TextPath
+from matplotlib.transforms import Affine2D
+
+
+def text3d(ax, (x, y, z), s, zdir="z", size=None, angle=0, usetex=False,
+ **kwargs):
+
+ if zdir == "y":
+ xy1, z1 = (x, z), y
+ elif zdir == "y":
+ xy1, z1 = (y, z), x
+ else:
+ xy1, z1 = (x, y), z
+
+ text_path = TextPath((0, 0), s, size=size, usetex=usetex)
+ trans = Affine2D().rotate(angle).translate(xy1[0], xy1[1])
+
+ p1 = PathPatch(trans.transform_path(text_path), **kwargs)
+ ax.add_patch(p1)
+ art3d.pathpatch_2d_to_3d(p1, z=z1, zdir=zdir)
+
+
+fig = plt.figure()
+ax = Axes3D(fig)
+
+p = Circle((5, 5), 3)
+ax.add_patch(p)
+art3d.pathpatch_2d_to_3d(p, z=0, zdir="x")
+
+
+text3d(ax, (4, -2, 0), "X-axis", zdir="z", size=.5, usetex=False,
+ ec="none", fc="k")
+text3d(ax, (12, 4, 0), "Y-axis", zdir="z", size=.5, usetex=False, angle=.5*3.14159,
+ ec="none", fc="k")
+text3d(ax, (12, 10, 4), "Z-axis", zdir="y", size=.5, usetex=False, angle=.5*3.14159,
+ ec="none", fc="k")
+
+text3d(ax, (1, 5, 0),
+ r"$\displaystyle G_{\mu\nu} + \Lambda g_{\mu\nu} = \frac{8\pi G}{c^4} T_{\mu\nu} $",
+ zdir="z", size=1, usetex=True,
+ ec="none", fc="k")
+
+ax.set_xlim3d(0, 10)
+ax.set_ylim3d(0, 10)
+ax.set_zlim3d(0, 10)
+
+plt.show()
+
Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py	2009年10月02日 18:58:20 UTC (rev 7841)
+++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py	2009年10月03日 18:11:09 UTC (rev 7842)
@@ -217,6 +217,31 @@
 def draw(self, renderer):
 Patch.draw(self, renderer)
 
+
+class PathPatch3D(Patch3D):
+ '''
+ 3D PathPatch object.
+ '''
+
+ def __init__(self, path, **kwargs):
+ zs = kwargs.pop('zs', [])
+ zdir = kwargs.pop('zdir', 'z')
+ Patch.__init__(self, **kwargs)
+ self.set_3d_properties(path, zs, zdir)
+
+ def set_3d_properties(self, path, zs=0, zdir='z'):
+ Patch3D.set_3d_properties(self, path.vertices, zs=zs, zdir=zdir)
+ self._code3d = path.codes
+
+ def do_3d_projection(self, renderer):
+ s = self._segment3d
+ xs, ys, zs = zip(*s)
+ vxs, vys,vzs, vis = proj3d.proj_transform_clip(xs, ys, zs, renderer.M)
+ self._path2d = mpath.Path(zip(vxs, vys), self._code3d)
+ # FIXME: coloring
+ self._facecolor2d = self._facecolor3d
+ return min(vzs)
+
 def get_patch_verts(patch):
 """Return a list of vertices for the path of a patch."""
 trans = patch.get_patch_transform()
@@ -233,6 +258,15 @@
 patch.__class__ = Patch3D
 patch.set_3d_properties(verts, z, zdir)
 
+def pathpatch_2d_to_3d(pathpatch, z=0, zdir='z'):
+ """Convert a PathPatch to a PathPatch3D object."""
+ path = pathpatch.get_path()
+ trans = pathpatch.get_patch_transform()
+
+ mpath = trans.transform_path(path)
+ pathpatch.__class__ = PathPatch3D
+ pathpatch.set_3d_properties(mpath, z, zdir)
+
 class Patch3DCollection(PatchCollection):
 '''
 A collection of 3D patches.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 1 results of 1

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /