Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2fb1f36

Browse files
committed
starting to fix up 3d modules
svn path=/trunk/matplotlib/; revision=2505
1 parent f17c5b1 commit 2fb1f36

5 files changed

Lines changed: 59 additions & 12 deletions

File tree

examples/embedding_in_wx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(self):
6262
# you don't need this under Linux
6363
tw, th = self.toolbar.GetSizeTuple()
6464
fw, fh = self.canvas.GetSizeTuple()
65-
self.toolbar.SetSize(wxSize(fw, th))
65+
self.toolbar.SetSize(wxSize(fw, th))
6666

6767
# Create a figure manager to manage things
6868
self.figmgr = FigureManager(self.canvas, 1, self)

examples/simple3d_oo.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python
2+
3+
import matplotlib
4+
matplotlib.use('WXAgg')
5+
matplotlib.rcParams['numerix'] = 'numarray'
6+
7+
from wxPython.wx import *
8+
import matplotlib.axes3d
9+
from matplotlib.figure import Figure
10+
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg, FigureManager, NavigationToolbar2WxAgg
11+
12+
class PlotFigure(wxFrame):
13+
def __init__(self):
14+
wxFrame.__init__(self, None, -1, "Test embedded wxFigure")
15+
16+
self.fig = Figure((9,8), 75)
17+
self.canvas = FigureCanvasWxAgg(self, -1, self.fig)
18+
self.toolbar = NavigationToolbar2WxAgg(self.canvas)
19+
self.toolbar.Realize()
20+
21+
self.figmgr = FigureManager(self.canvas, 1, self)
22+
tw, th = self.toolbar.GetSizeTuple()
23+
fw, fh = self.canvas.GetSizeTuple()
24+
self.toolbar.SetSize(wxSize(fw, th))
25+
sizer = wxBoxSizer(wxVERTICAL)
26+
27+
# This way of adding to sizer allows resizing
28+
sizer.Add(self.canvas, 1, wxLEFT|wxTOP|wxGROW)
29+
sizer.Add(self.toolbar, 0, wxGROW)
30+
self.SetSizer(sizer)
31+
self.Fit()
32+
33+
self.plot3d()
34+
35+
def plot3d(self):
36+
ax3d = matplotlib.axes3d.Axes3D(self.fig)
37+
plt = self.fig.axes.append(ax3d)
38+
39+
if __name__ == '__main__':
40+
app = wxPySimpleApp(0)
41+
frame = PlotFigure()
42+
frame.Show()
43+
app.MainLoop()

lib/matplotlib/axes3d.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import cbook
2020
from transforms import unit_bbox
2121

22+
import figure
2223
import numerix as nx
2324
from colors import normalize
2425

@@ -56,8 +57,8 @@ class Axes3DI(Axes):
5657
"""
5758
def __init__(self, fig=None, rect=[0.0, 0.0, 1.0, 1.0], *args, **kwargs):
5859
#
59-
fig = fig or pylab.gcf()
60-
60+
self.fig = fig or figure.Figure()
61+
6162
azim = cbook.popd(kwargs, 'azim', -60)
6263
elev = cbook.popd(kwargs, 'elev', 30)
6364

@@ -70,12 +71,12 @@ def __init__(self, fig=None, rect=[0.0, 0.0, 1.0, 1.0], *args, **kwargs):
7071
# inihibit autoscale_view until the axises are defined
7172
# they can't be defined until Axes.__init__ has been called
7273
self._ready = 0
73-
Axes.__init__(self, fig, rect,
74+
Axes.__init__(self, self.fig, rect,
7475
frameon=True,
7576
xticks=[], yticks=[], *args, **kwargs)
7677
#
77-
figmanager = pylab.get_current_fig_manager()
78-
self.toolbar = figmanager.toolbar
78+
# figmanager = pylab.get_current_fig_manager()
79+
# self.toolbar = figmanager.toolbar
7980
#
8081
#
8182
# self.toolbar._active is current zoom/pan mode
@@ -85,14 +86,14 @@ def __init__(self, fig=None, rect=[0.0, 0.0, 1.0, 1.0], *args, **kwargs):
8586
self._ready = 1
8687

8788
self.view_init(elev, azim)
88-
self.mouse_init()
89+
#self.mouse_init()
8990
self.create_axes()
9091
self.set_top_view()
9192

9293
#self.axesPatch.set_edgecolor((1,0,0,0))
9394
self.axesPatch.set_linewidth(0)
9495
#self.axesPatch.set_facecolor((0,0,0,0))
95-
fig.add_axes(self)
96+
self.fig.add_axes(self)
9697

9798

9899
def set_top_view(self):
@@ -148,7 +149,8 @@ def unit_cube(self,vals=None):
148149
return zip(xs,ys,zs)
149150

150151
def tunit_cube(self,vals=None,M=None):
151-
M = M or self.M
152+
if M is None:
153+
M = self.M
152154
xyzs = self.unit_cube(vals)
153155
tcube = proj3d.proj_points(xyzs,M)
154156
return tcube

lib/matplotlib/axis3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def get_major_ticks(self):
153153
def update_coords(renderer,self=t.label1):
154154
return text_update_coords(self, renderer)
155155
# Text overrides setattr so need this to force new method
156-
t.label1.__dict__['update_coords'] = update_coords
156+
#t.label1.__dict__['update_coords'] = update_coords
157157
t.tick1line.set_transform(self.axes.transData)
158158
t.tick2line.set_transform(self.axes.transData)
159159
t.gridline.set_transform(self.axes.transData)

lib/matplotlib/proj3d.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from collections import LineCollection
1010
from patches import Circle
1111
import numerix as nx
12+
from numerix import linear_algebra
1213
from math import sqrt
1314

1415
dot = nx.dot
@@ -18,14 +19,15 @@ def _hide_dot(a,b):
1819
"""
1920
return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]
2021

21-
cross = nx.cross
22+
#cross = nx.cross
2223
def _hide_cross(a,b):
2324
"""
2425
Cross product of two vectors
2526
A x B = <Ay*Bz - Az*By, Az*Bx - Ax*Bz, Ax*By - Ay*Bx>
2627
a x b = [a2b3 - a3b2, a3b1 - a1b3, a1b2 - a2b1]
2728
"""
2829
return nx.array([a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1] - a[1]*b[0]])
30+
cross = _hide_cross
2931

3032

3133
def test_dot():
@@ -215,7 +217,7 @@ def proj_transform_vec_clip(vec, M):
215217
return txs,tys,tzs,tis
216218

217219
def inv_transform(xs,ys,zs,M):
218-
iM = nx.linalg.inv(M)
220+
iM = linear_algebra.inverse(M)
219221
vec = vec_pad_ones(xs,ys,zs)
220222
vecr = nx.matrixmultiply(iM,vec)
221223
try:

0 commit comments

Comments
 (0)