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

Skip to content

Commit 86424bf

Browse files
committed
restored axes frame, made patch edge invisible
svn path=/trunk/matplotlib/; revision=5909
1 parent 94c4068 commit 86424bf

2 files changed

Lines changed: 57 additions & 3 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import wx
2+
import wx.aui
3+
import matplotlib as mpl
4+
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
5+
from matplotlib.backends.backend_wxagg import NavigationToolbar2Wx as Toolbar
6+
7+
class Plot(wx.Panel):
8+
def __init__(self, parent, id = -1, dpi = None, **kwargs):
9+
wx.Panel.__init__(self, parent, id=id, **kwargs)
10+
self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2,2))
11+
self.canvas = Canvas(self, -1, self.figure)
12+
self.toolbar = Toolbar(self.canvas)
13+
self.toolbar.Realize()
14+
15+
sizer = wx.BoxSizer(wx.VERTICAL)
16+
sizer.Add(self.canvas,1,wx.EXPAND)
17+
sizer.Add(self.toolbar, 0 , wx.LEFT | wx.EXPAND)
18+
self.SetSizer(sizer)
19+
20+
class PlotNotebook(wx.Panel):
21+
def __init__(self, parent, id = -1):
22+
wx.Panel.__init__(self, parent, id=id)
23+
self.nb = wx.aui.AuiNotebook(self)
24+
sizer = wx.BoxSizer()
25+
sizer.Add(self.nb, 1, wx.EXPAND)
26+
self.SetSizer(sizer)
27+
28+
def add(self,name="plot"):
29+
page = Plot(self.nb)
30+
self.nb.AddPage(page,name)
31+
return page.figure
32+
33+
34+
def demo():
35+
app = wx.PySimpleApp()
36+
frame = wx.Frame(None,-1,'Plotter')
37+
plotter = PlotNotebook(frame)
38+
axes1 = plotter.add('figure 1').gca()
39+
axes1.plot([1,2,3],[2,1,4])
40+
axes2 = plotter.add('figure 2').gca()
41+
axes2.plot([1,2,3,4,5],[2,1,4,2,3])
42+
#axes1.figure.canvas.draw()
43+
#axes2.figure.canvas.draw()
44+
frame.Show()
45+
app.MainLoop()
46+
47+
if __name__ == "__main__": demo()
48+

lib/matplotlib/axes.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -845,12 +845,14 @@ def cla(self):
845845
self._set_artist_props(self.title)
846846

847847
# the patch draws the background of the axes. we want this to
848-
# be below the other artists; the axesPatch name is deprecated
848+
# be below the other artists; the axesPatch name is
849+
# deprecated. We use the frame to draw the edges so we are
850+
# setting the edgecolor to None
849851
self.patch = self.axesPatch = self._gen_axes_patch()
850852
self.patch.set_figure(self.figure)
851853
self.patch.set_facecolor(self._axisbg)
852-
self.patch.set_edgecolor(rcParams['axes.edgecolor'])
853-
self.patch.set_linewidth(rcParams['axes.linewidth'])
854+
self.patch.set_edgecolor('None')
855+
self.patch.set_linewidth(0)
854856
self.patch.set_transform(self.transAxes)
855857

856858
# the frame draws the border around the axes and we want this
@@ -1504,6 +1506,10 @@ def draw(self, renderer=None, inframe=False):
15041506
if self.legend_ is not None:
15051507
artists.append(self.legend_)
15061508

1509+
if self.axison and self._frameon:
1510+
artists.append(self.frame)
1511+
1512+
15071513
dsu = [ (a.zorder, i, a) for i, a in enumerate(artists)
15081514
if not a.get_animated() ]
15091515
dsu.sort()

0 commit comments

Comments
 (0)