## Re: [PyX-user] Assembling graph.data.values For Plotting -- SOLVED

 Re: [PyX-user] Assembling graph.data.values For Plotting -- SOLVED From: Alan G Isaac - 2008-04-01 18:53:34 ```On Tue, 1 Apr 2008, Rich Shepard apparently wrote: > I'm liking PyX more and more now that > I'm learning how to effectively use it. PyX is awesome. Cheers, Alan ```

 [PyX-user] Assembling graph.data.values For Plotting From: Rich Shepard - 2008-04-01 17:01:30 ``` I need to assemble all curves for a single plot before calling the plot command. I've tried doing this using a list, and appending the graph.data.values() for each curve to it. But, it's not working. For example, when trying to plot both linear increasing and linear decreasing curves on the same axes, only the last one called is plotted. The calling function includes this code: elif row[4] == 'Linear Increasing': testFunctions.linearIncrCurve(row[8],row[11]) curveList.append(graph.data.values(x=appData.plotX, y=appData.plotY)) appData.plotX = None appData.plotY = None elif row[4] == 'Linear Decreasing': testFunctions.linearDecrCurve(row[10],row[9]) curveList.append(graph.data.values(x=appData.plotX, y=appData.plotY)) appData.plotX = None appData.plotY = None The two functions in the testFunctions module are: def linearIncrCurve(ll, hr): lowLeft = ll highRight = hr x, y = zip(*[(lowLeft, 0.0), (highRight, 1.0)]) appData.plotX = x appData.plotY = y def linearDecrCurve(hl, lr): highLeft = hl lowRight = lr x, y = zip(*[(highLeft, 1.0), (lowRight, 0.0)]) appData.plotX = x appData.plotY = y It appears the reason I cannot create a list of these curves is that they are pyx.graph.graph.graphxy.instances rather than string or numeric data. I'd appreciate suggestions on how to accumulate the appropriate curves for a single plot that holds them all until the plot() function is called. Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation ; Voice: 503-667-4517 Fax: 503-667-8863 ```
 Re: [PyX-user] Assembling graph.data.values For Plotting -- SOLVED From: Rich Shepard - 2008-04-01 18:11:08 ```On Tue, 1 Apr 2008, Rich Shepard wrote: > I need to assemble all curves for a single plot before calling the plot > command. I've tried doing this using a list, and appending the > graph.data.values() for each curve to it. But, it's not working. User error: I created the list within the for loop so it was cleared each time. Now it works as intended. Thanks for everyone's patient help. I'm liking PyX more and more now that I'm learning how to effectively use it. Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation ; Voice: 503-667-4517 Fax: 503-667-8863 ```
 Re: [PyX-user] Assembling graph.data.values For Plotting -- SOLVED From: Alan G Isaac - 2008-04-01 18:53:34 ```On Tue, 1 Apr 2008, Rich Shepard apparently wrote: > I'm liking PyX more and more now that > I'm learning how to effectively use it. PyX is awesome. Cheers, Alan ```
 Re: [PyX-user] Assembling graph.data.values For Plotting -- SOLVED From: Rich Shepard - 2008-04-01 19:22:12 ```On Tue, 1 Apr 2008, Alan G Isaac wrote: > PyX is awesome. Alan, It really is. Now, one remaining issue (other than labeling curve on the plots, but that's for later): I cannot print multiple plots successively. Apparently, the g.plot() function doesn't clear between plots. Here's where the plotting is done: if row[5] == row[16]: g.plot(curveList,[graph.style.line([style.linewidth.Thin])]) print curveList g.writePDFfile(curComp + '_' + curSub + '_' + curVar) plotting = False curveList = [] and I print curveList at the top of the for loop. Here's the output (with my explanation interspaced): \$ python testData.py [] ## We've just entered the for loop for the first plot [] [, ] ## Here are the two curves for the first plot in the data; this is written ## to disk. Then we're back at the top for the second plot in the sample ## data: [] [] [, ] ## These are the three curves for the second plot. The list has been cleared ## and the proper curves accumulated. Then I see this: /usr/lib/python2.4/site-packages/pyx/graph/graph.py:171: UserWarning: axes ranges have already been analysed; no further adjustments will be performed warnings.warn("axes ranges have already been analysed; no further adjustments will be performed") Traceback (most recent call last): File "testData.py", line 123, in ? testCode() File "testData.py", line 116, in testCode g.plot(curveList,[graph.style.line([style.linewidth.Thin])]) File "/usr/lib/python2.4/site-packages/pyx/graph/graph.py", line 173, in plot raise RuntimeError("can't plot further data after dostyles() has been executed") RuntimeError: can't plot further data after dostyles() has been executed So, the problem is with the second call to g.plot(). How can I clear/reset axes, styles, etc. between calls? Thanks, Rich -- Richard B. Shepard, Ph.D. | Integrity Credibility Applied Ecosystem Services, Inc. | Innovation ; Voice: 503-667-4517 Fax: 503-667-8863 ```
 Re: [PyX-user] Assembling graph.data.values For Plotting -- SOLVED From: Alan Isaac - 2008-04-02 15:41:38 ```On Tue, 1 Apr 2008, Rich Shepard wrote: > the g.plot() function doesn't clear between plots. > RuntimeError: can't plot further data after dostyles() has > been executed > So, the problem is with the second call to g.plot(). How > can I clear/reset axes, styles, etc. between calls? Your ``g`` is a ``graph.graphxy`` **instance**. Once you call its plot method, you have created its plot. It's done with that activity. Just make a new instance for your next plot. Cheers, Alan ```