From 26a273afe93d81463012e8b099ed6b64eb236944 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Wobst?= Date: Thu, 10 Aug 2006 13:47:07 +0000 Subject: [PATCH] doplot method (to be called with a plotitem) to alter the plotitem order etc. git-svn-id: https://pyx.svn.sourceforge.net/svnroot/pyx/trunk/pyx@2848 069f4177-920e-0410-937b-c2a4a81bcd90 --- CHANGES | 2 ++ pyx/graph/graph.py | 27 +++++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index dd78cb17..384f64a2 100644 --- a/CHANGES +++ b/CHANGES @@ -94,6 +94,8 @@ TODO: - painter: don't insert axis title twice (thanks to Tim Gray for reporting this problem) - graph styles: - optional textdx/textdy columns to the text style added (TODO: documentation) + - graph module: + - doplot method (to be called with a plotitem) to alter the plotitem order etc. (TODO: documentation) - attr module: - add multichangeattr to perform a select on different changeable attributes depending on the selects total number diff --git a/pyx/graph/graph.py b/pyx/graph/graph.py index 780bdbc6..6be41152 100644 --- a/pyx/graph/graph.py +++ b/pyx/graph/graph.py @@ -130,7 +130,7 @@ class graph(canvas.canvas): self.plotitems = [] self._calls = {} self.didranges = 0 - self.diddata = 0 + self.didstyles = 0 def did(self, method, *args, **kwargs): if not self._calls.has_key(method): @@ -164,8 +164,8 @@ class graph(canvas.canvas): def plot(self, data, styles=None, rangewarning=1): if self.didranges and rangewarning: warnings.warn("axes ranges have already been analysed; no further adjustments will be performed") - if self.diddata: - raise RuntimeError("can't plot further data after dodata() has been executed") + if self.didstyles: + raise RuntimeError("can't plot further data after dostyles() has been executed") singledata = 0 try: for d in data: @@ -219,8 +219,8 @@ class graph(canvas.canvas): def doaxes(self): raise NotImplementedError - def dodata(self): - if self.did(self.dodata): + def dostyles(self): + if self.did(self.dostyles): return self.dolayout() self.dobackground() @@ -243,10 +243,17 @@ class graph(canvas.canvas): plotitem.selectstyles(self, styleindex[stylesid(plotitem.styles)], styletotal[stylesid(plotitem.styles)]) - for plotitem in self.plotitems: - plotitem.draw(self) + self.didstyles = 1 + + def doplot(self, plotitem): + if self.did(self.doplot, plotitem): + return + self.dostyles() + plotitem.draw(self) - self.diddata = 1 + def dodata(self): + for plotitem in self.plotitems: + self.doplot(plotitem) def dokey(self): raise NotImplementedError @@ -478,7 +485,7 @@ class graphxy(graph): if self.did(self.dokey): return self.dobackground() - self.dodata() + self.dostyles() if self.key is not None: c = self.key.paint(self.plotitems) bbox = c.bbox() @@ -741,7 +748,7 @@ class graphxyz(graphxy): if self.did(self.dokey): return self.dobackground() - self.dodata() + self.dostyles() if self.key is not None: c = self.key.paint(self.plotitems) bbox = c.bbox() -- 2.11.4.GIT