From: <joergl@us...>  20060521 15:16:42

Revision: 2745 Author: joergl Date: 20060521 08:16:32 0700 (Sun, 21 May 2006) ViewCVS: http://svn.sourceforge.net/pyx/?rev=2745&view=rev Log Message:  more graphs example work Modified Paths:  trunk/pyx/examples/graphs/INDEX trunk/pyx/examples/graphs/lissajous.txt trunk/pyx/examples/graphs/minimal.py trunk/pyx/examples/graphs/minimal.txt Added Paths:  trunk/pyx/examples/graphs/function.py trunk/pyx/examples/graphs/function.txt Modified: trunk/pyx/examples/graphs/INDEX ===================================================================  trunk/pyx/examples/graphs/INDEX 20060520 15:46:35 UTC (rev 2744) +++ trunk/pyx/examples/graphs/INDEX 20060521 15:16:32 UTC (rev 2745) @@ 1,4 +1,5 @@ minimal +function errorbar histogram lissajous Added: trunk/pyx/examples/graphs/function.py ===================================================================  trunk/pyx/examples/graphs/function.py (rev 0) +++ trunk/pyx/examples/graphs/function.py 20060521 15:16:32 UTC (rev 2745) @@ 0,0 +1,6 @@ +from pyx import * + +g = graph.graphxy(width=8) +g.plot(graph.data.function("y(x)=sin(x)/x", min=15, max=15)) +g.writeEPSfile("function") +g.writePDFfile("function") Added: trunk/pyx/examples/graphs/function.txt ===================================================================  trunk/pyx/examples/graphs/function.txt (rev 0) +++ trunk/pyx/examples/graphs/function.txt 20060521 15:16:32 UTC (rev 2745) @@ 0,0 +1,32 @@ +Plotting a mathematical function + +Here, we explain how to plot the graph of a realvalued mathematical function of +a single real parameter. ... + +As in the previous example, we first create a `graph.graphxy` instance passing +the width as argument. We then pass a `graph.data.function` instance to the +`plot` method of the graph. As first argument, we pass the function in the form +"y(x) = f(x)". Here, the lefthand side of the equation defines which parameter +is independent (here: `x`) and which one is dependent (here: `y`). We also need +to inform PyX about the range of the independent variable. This is done by passing +the parameters `min` and `max`. + +! In order to increase the resolution of the function graph, you can use the +parameter `points` of the `graph.data.function` class to increase the number of +sampling points from its default value of `100`. + +Note that the default graph style for function data is `graph.style.line` synce +PyX assumes a continuous xrange. + +! You only need to pass the `min` and `max` parameters to the +`graph.data.function` class, if PyX cannot figure out an axis range by itself. +Thus, an alternative way to achieve the above result would look like + g = graph.graphxy(width=8, x=graph.axis.linear(min=15, max=15)) + g.plot(graph.data.function("y(x)=sin(x)/x")) +Here, we explicitely define an xaxis range by passing an appropriate +argument to the `x` parameter of the `graph.graphxy` class. + +! For PyX it does not matter, whether you plot a function of a parameter `x` or +a parameter `y`. Thus, you may as well write + g.plot(graph.data.function("x(y)=sin(y)/y", min=15, max=15)) +to obtain a plot where the ycoordinate is the independent one. Modified: trunk/pyx/examples/graphs/lissajous.txt ===================================================================  trunk/pyx/examples/graphs/lissajous.txt 20060520 15:46:35 UTC (rev 2744) +++ trunk/pyx/examples/graphs/lissajous.txt 20060521 15:16:32 UTC (rev 2745) @@ 5,7 +5,7 @@ argument, a minimal and a maximal value given as the second and third argument and an expression string as forth argument. ... This expression string assigns a tuple of expressions to a tuple of data names. As usual the styles will decide #what those data names are responsible for. +what those data names are responsible for. ! Like for the function, you can also access external data and functions in your expression. Suppose we want to provide the data for this example by means of Modified: trunk/pyx/examples/graphs/minimal.py ===================================================================  trunk/pyx/examples/graphs/minimal.py 20060520 15:46:35 UTC (rev 2744) +++ trunk/pyx/examples/graphs/minimal.py 20060521 15:16:32 UTC (rev 2745) @@ 4,14 +4,3 @@ g.plot(graph.data.file("minimal.dat", x=1, y=2)) g.writeEPSfile("minimal") g.writePDFfile("minimal")  # the file minimal.dat looks like: # 1 2 # 2 3 # 3 8 # 4 13 # 5 18 # 6 21  # graph styles can be modified by a second parameter to the plot method: # g.plot(graph.data.file("minimal.dat", x=1, y=2), [graph.style.line()]) Modified: trunk/pyx/examples/graphs/minimal.txt ===================================================================  trunk/pyx/examples/graphs/minimal.txt 20060520 15:46:35 UTC (rev 2744) +++ trunk/pyx/examples/graphs/minimal.txt 20060521 15:16:32 UTC (rev 2745) @@ 1,6 +1,15 @@ Basic graph drawing: data contained in a file +Plotting data contained in a file This example shows how to draw a graph representing data stored in a file. ... +We assume that the data is arranged in the file `minimal.dat` in a whitespaceseparated +twocolumn form: + # minimal.dat + 1 2 + 2 3 + 3 8 + 4 13 + 5 18 + 6 21 The first step is to create an instance of the `graphxy` class which can be found in the `graph` module. By convention, we call it `g`. The constructor @@ 18,10 +27,33 @@ column of the file contains the x (y) values. The `graph.data.file` instance is then directly passed to the `plot` method of the graph `g`. +! Note that PyX by default ignores comments starting by a # sign when reading +in the data from the file. + +!! The previous statement is actually not completely correct, as PyX +uses the last comment preceding the actual data to give names to the columns. +Thus, for a file looking like + # my data (this line is ignored by PyX, but not the following) + # x y + 1 2 + ... +you wouldn't need to label the columns in the `graph.data.file` call at all. + Finally, we write the graph to an EPS and PDF file. Here, we use that every graph is (by inheritance) an instance of the `canvas` class, as well, such that we can directly write it into a file. ! Of course, you can also insert a graph into another canvas and write this canvas later to a file. This way, you can, for instance, easily arrange more than one graph on a page. +than one graph on a page. Later examples will make use of this fact. + +In PyX, the way data is plotted in a graph is defined by a socalled graph +style. A couple of standard graph styles are contained in the module +`graph.style`. Depending on the data source, PyX chooses a default style. Here, +we are taking the data from a file and PyX assumes that the values represent a +discrete set of data points. Hence, it chooses the symbol style +`graph.style.symbol` to plot the data. To override this default behaviour, you +can pass a list of styles as second argument to the `plot` method. For instance, +to have PyX drawing a line through the data points, you can use + + g.plot(graph.data.file("minimal.dat", x=1, y=2), [graph.style.line()]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. 
From: <joergl@us...>  20060521 16:21:04

Revision: 2748 Author: joergl Date: 20060521 09:20:45 0700 (Sun, 21 May 2006) ViewCVS: http://svn.sourceforge.net/pyx/?rev=2748&view=rev Log Message:  add a gentle introduction to axes (Andre, please have a look at the XXX part) Modified Paths:  trunk/pyx/examples/graphs/INDEX Added Paths:  trunk/pyx/examples/graphs/axis.py trunk/pyx/examples/graphs/axis.txt Modified: trunk/pyx/examples/graphs/INDEX ===================================================================  trunk/pyx/examples/graphs/INDEX 20060521 15:26:42 UTC (rev 2747) +++ trunk/pyx/examples/graphs/INDEX 20060521 16:20:45 UTC (rev 2748) @@ 2,6 +2,7 @@ function lissajous histogram +axis errorbar piaxis manyaxes Added: trunk/pyx/examples/graphs/axis.py ===================================================================  trunk/pyx/examples/graphs/axis.py (rev 0) +++ trunk/pyx/examples/graphs/axis.py 20060521 16:20:45 UTC (rev 2748) @@ 0,0 +1,8 @@ +from pyx import * + +g = graph.graphxy(width=8, + x=graph.axis.log(min=1e1, max=1e4), + y=graph.axis.lin(min=5, max=5)) +g.plot(graph.data.function("y(x)=tan(log(1/x))")) +g.writeEPSfile("axis") +g.writePDFfile("axis") Added: trunk/pyx/examples/graphs/axis.txt ===================================================================  trunk/pyx/examples/graphs/axis.txt (rev 0) +++ trunk/pyx/examples/graphs/axis.txt 20060521 16:20:45 UTC (rev 2748) @@ 0,0 +1,27 @@ +Using a logarithmic axis and defining the axis range + +Sometimes, you have to visualize rather pathological funtions containing +divergencies and/or varying over a large parameter range. This is best done +using an appropriate axis. Here, we show a simple example how to do +this with PyX. ... + +In order to change the properties of the graph axes, we have to create +appropriate instances of an axis class and pass them as keyword arguments to +the `graph.graphxy` constructor. A number of predefined axes is contained in +the `graph.axis` module. Here, we use a linear (abbreviated as +`graph.axis.lin`) and a logarithmic (abbreviated as `graph.axis.log`) axis. In +both cases, we pass a minimal and maximal value for the axis range. Whereas for +the xaxis this is not strictly necessary (we could as well tell the +`graph.data.function` instance to emit data in a certain xrange), it is +important for the yaxis because the function diverges for certain x values. If +we do not set the y range manually, we would obtain a rather compressed display +of the function in the ydirection, which, moreover, would strongly depend on +the sampling points choosen by PyX along the xdirection. + +! Note how PyX changes the way the xaxis is drawn. Instead of simple decimal +numbers, an exponential notation is used. This happens automatically, if the axis +values become too big. + +XXX Andre, please more info: I don't feel being qualified enough + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. 
From: <joergl@us...>  20060521 19:03:05

Revision: 2752 Author: joergl Date: 20060521 12:02:55 0700 (Sun, 21 May 2006) ViewCVS: http://svn.sourceforge.net/pyx/?rev=2752&view=rev Log Message:  describe plotting of more than one data set and graph key Modified Paths:  trunk/pyx/examples/graphs/INDEX trunk/pyx/examples/graphs/change.py Modified: trunk/pyx/examples/graphs/INDEX ===================================================================  trunk/pyx/examples/graphs/INDEX 20060521 18:27:14 UTC (rev 2751) +++ trunk/pyx/examples/graphs/INDEX 20060521 19:02:55 UTC (rev 2752) @@ 4,9 +4,9 @@ histogram axis errorbar +change piaxis manyaxes inset link change arrows Modified: trunk/pyx/examples/graphs/change.py ===================================================================  trunk/pyx/examples/graphs/change.py 20060521 18:27:14 UTC (rev 2751) +++ trunk/pyx/examples/graphs/change.py 20060521 19:02:55 UTC (rev 2752) @@ 1,10 +1,14 @@ from pyx import * g = graph.graphxy(width=10, +g = graph.graphxy(width=8, x=graph.axis.linear(min=0, max=2),  y=graph.axis.linear(min=0, max=2)) g.plot([graph.data.function("x(y)=y**(2**(3%i))" % i) for i in range(3)] +  [graph.data.function("y(x)=x**(2**%i)" % i) for i in range(4)], + y=graph.axis.linear(min=0, max=2), + key=graph.key.key(pos="br", dist=0.1)) +g.plot([graph.data.function("x(y)=y**(2**%i)" % i, title=r"$x = y^{%g}$" % (2**i)) + for i in range(2, 0, 1)] + + [graph.data.function("x(y)=y", title=r"$x = y$")] + + [graph.data.function("y(x)=x**(2**%i)" % i, title=r"$y = x^{%g}$" % (2**i)) + for i in range(1, 3)], [graph.style.line([color.palette.Rainbow])]) g.writeEPSfile("change") g.writePDFfile("change") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. 
From: <joergl@us...>  20060521 19:09:16

Revision: 2754 Author: joergl Date: 20060521 12:09:09 0700 (Sun, 21 May 2006) ViewCVS: http://svn.sourceforge.net/pyx/?rev=2754&view=rev Log Message:  some updates to titles Modified Paths:  trunk/pyx/examples/graphs/function.txt trunk/pyx/examples/graphs/lissajous.txt Modified: trunk/pyx/examples/graphs/function.txt ===================================================================  trunk/pyx/examples/graphs/function.txt 20060521 19:03:12 UTC (rev 2753) +++ trunk/pyx/examples/graphs/function.txt 20060521 19:09:09 UTC (rev 2754) @@ 1,4 +1,4 @@ Plotting a mathematical function +Plotting a function graph Here, we explain how to plot the graph of a realvalued mathematical function of a single real parameter. ... Modified: trunk/pyx/examples/graphs/lissajous.txt ===================================================================  trunk/pyx/examples/graphs/lissajous.txt 20060521 19:03:12 UTC (rev 2753) +++ trunk/pyx/examples/graphs/lissajous.txt 20060521 19:09:09 UTC (rev 2754) @@ 1,4 +1,4 @@ Parametric function +Plotting a parametric function This example shows how to use a `paramfunction` as a data source for a graph. `paramfunction` defines a parameter variable name given as a string in the first This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. 
From: <joergl@us...>  20060522 20:29:44

Revision: 2781 Author: joergl Date: 20060522 13:29:30 0700 (Mon, 22 May 2006) ViewCVS: http://svn.sourceforge.net/pyx/?rev=2781&view=rev Log Message:  prevent vertical lines at divergencies Modified Paths:  trunk/pyx/examples/graphs/axis.py trunk/pyx/examples/graphs/axis.txt Modified: trunk/pyx/examples/graphs/axis.py ===================================================================  trunk/pyx/examples/graphs/axis.py 20060522 19:47:35 UTC (rev 2780) +++ trunk/pyx/examples/graphs/axis.py 20060522 20:29:30 UTC (rev 2781) @@ 2,7 +2,7 @@ g = graph.graphxy(width=8, x=graph.axis.log(min=1e1, max=1e4),  y=graph.axis.lin(min=5, max=5)) g.plot(graph.data.function("y(x)=tan(log(1/x))")) + y=graph.axis.lin(max=5)) +g.plot(graph.data.function("y(x)=tan(log(1/x))**2")) g.writeEPSfile("axis") g.writePDFfile("axis") Modified: trunk/pyx/examples/graphs/axis.txt ===================================================================  trunk/pyx/examples/graphs/axis.txt 20060522 19:47:35 UTC (rev 2780) +++ trunk/pyx/examples/graphs/axis.txt 20060522 20:29:30 UTC (rev 2781) @@ 16,7 +16,10 @@ important for the yaxis because the function diverges for certain x values. If we do not set the y range manually, we would obtain a rather compressed display of the function in the ydirection, which, moreover, would strongly depend on the sampling points choosen by PyX along the xdirection. +the sampling points choosen by PyX along the xdirection. Since the function only +diverges towards positive yvalues, we only need to set the maximal value of +the yaxis (using the `max`argument). Of course, you can also fix the lower end +of the axis range by providing a `min`argument. ! Note how PyX changes the way the xaxis is drawn. Instead of simple decimal numbers, an exponential notation is used. This happens automatically by This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. 
From: <wobsta@us...>  20060523 12:35:17

Revision: 2798 Author: wobsta Date: 20060523 05:35:06 0700 (Tue, 23 May 2006) ViewCVS: http://svn.sourceforge.net/pyx/?rev=2798&view=rev Log Message:  remove the lists in the data creation ... and add a note to the description Modified Paths:  trunk/pyx/examples/graphs/change.py trunk/pyx/examples/graphs/change.txt Modified: trunk/pyx/examples/graphs/change.py ===================================================================  trunk/pyx/examples/graphs/change.py 20060523 09:56:34 UTC (rev 2797) +++ trunk/pyx/examples/graphs/change.py 20060523 12:35:06 UTC (rev 2798) @@ 4,11 +4,11 @@ x=graph.axis.linear(min=0, max=2), y=graph.axis.linear(min=0, max=2), key=graph.key.key(pos="br", dist=0.1)) g.plot([graph.data.function("x(y)=y**(2**%i)" % i, title=r"$x = y^{%g}$" % (2**i))  for i in range(2, 0, 1)] +  [graph.data.function("x(y)=y", title=r"$x = y$")] +  [graph.data.function("y(x)=x**(2**%i)" % i, title=r"$y = x^{%g}$" % (2**i))  for i in range(1, 3)], +g.plot([graph.data.function("x(y)=y**4", title=r"$x = y^4$"), + graph.data.function("x(y)=y**2", title=r"$x = y^2$"), + graph.data.function("x(y)=y", title=r"$x = y$"), + graph.data.function("y(x)=x**2", title=r"$y = x^2$"), + graph.data.function("y(x)=x**4", title=r"$y = x^4$")], [graph.style.line([color.palette.Rainbow])]) g.writeEPSfile("change") g.writePDFfile("change") Modified: trunk/pyx/examples/graphs/change.txt ===================================================================  trunk/pyx/examples/graphs/change.txt 20060523 09:56:34 UTC (rev 2797) +++ trunk/pyx/examples/graphs/change.txt 20060523 12:35:06 UTC (rev 2798) @@ 25,6 +25,11 @@ of the corresponding class: graph.style.line([style.linestyle.clear, color.palette.Rainbow]) +!! It is also possible to call the `plot` method several times. Note that the +changing of the styles is also performed when the style instances are used on +several plot commands within the same graph as long as the same set of style +instances are passed at the `plot` method calls. + Finally, when plotting more than one data set you might want to label them in your graph. We already have passed titles identifying each data set, so we only have to add a graph key. This is done by passing a `graph.key.key` instance as This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. 
From: <mschindler@us...>  20080325 16:17:32

Revision: 2971 http://pyx.svn.sourceforge.net/pyx/?rev=2971&view=rev Author: mschindler Date: 20080325 09:17:36 0700 (Tue, 25 Mar 2008) Log Message:  added an example for the plotting of points Modified Paths:  trunk/pyx/examples/graphs/INDEX Added Paths:  trunk/pyx/examples/graphs/points.py trunk/pyx/examples/graphs/points.txt Modified: trunk/pyx/examples/graphs/INDEX ===================================================================  trunk/pyx/examples/graphs/INDEX 20080325 14:07:10 UTC (rev 2970) +++ trunk/pyx/examples/graphs/INDEX 20080325 16:17:36 UTC (rev 2971) @@ 1,5 +1,6 @@ minimal function +points lissajous axis change Added: trunk/pyx/examples/graphs/points.py ===================================================================  trunk/pyx/examples/graphs/points.py (rev 0) +++ trunk/pyx/examples/graphs/points.py 20080325 16:17:36 UTC (rev 2971) @@ 0,0 +1,9 @@ +# contributed by Chris Spencer + +from pyx import * + +g = graph.graphxy(width=8) +g.plot(graph.data.points(zip(range(10),range(10)), x=1, y=2)) +g.writeEPSfile("points") +g.writePDFfile("points") + Added: trunk/pyx/examples/graphs/points.txt ===================================================================  trunk/pyx/examples/graphs/points.txt (rev 0) +++ trunk/pyx/examples/graphs/points.txt 20080325 16:17:36 UTC (rev 2971) @@ 0,0 +1,18 @@ +Plotting a list of data points + +Here, we explain how to plot data which has been calculated before and which is +contained in a list. ... + +The procedure is quite the same as for plotting a data file or a function in +the above examples. The difference is that we here use a `graph.data.points` +instance to the `plot` method of the graph. It takes a list of data points +which come as tuples. You will have to say something like `x=1, y=2` to specify +which entry in your tuples is to be used on which axis. + +Similarly to the plotting of a data file, the default plotting style is with +symbols. This appears to be the the natural choice, since the data is of +discrete nature. + +Caution: This feature has been renamed between versions 0.9 and 0.10. The old +name in version 0.9 and before was `graph.data.list`. + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. 
From: <mschindler@us...>  20080325 17:25:49

Revision: 2972 http://pyx.svn.sourceforge.net/pyx/?rev=2972&view=rev Author: mschindler Date: 20080325 10:25:55 0700 (Tue, 25 Mar 2008) Log Message:  added graph.data.values to the points example Modified Paths:  trunk/pyx/examples/graphs/points.py trunk/pyx/examples/graphs/points.txt Modified: trunk/pyx/examples/graphs/points.py ===================================================================  trunk/pyx/examples/graphs/points.py 20080325 16:17:36 UTC (rev 2971) +++ trunk/pyx/examples/graphs/points.py 20080325 17:25:55 UTC (rev 2972) @@ 1,9 +1,12 @@ # contributed by Chris Spencer +# suggested by Chris Spencer from pyx import * g = graph.graphxy(width=8) g.plot(graph.data.points(zip(range(10),range(10)), x=1, y=2)) +# either provide lists of the individual coordinates +g.plot(graph.data.values(x=range(10), y=range(10))) +# or provide one list containing the whole points +g.plot(graph.data.points(zip(range(10), range(10)), x=1, y=2)) g.writeEPSfile("points") g.writePDFfile("points") Modified: trunk/pyx/examples/graphs/points.txt ===================================================================  trunk/pyx/examples/graphs/points.txt 20080325 16:17:36 UTC (rev 2971) +++ trunk/pyx/examples/graphs/points.txt 20080325 17:25:55 UTC (rev 2972) @@ 1,18 +1,22 @@ Plotting a list of data points +Plotting data contained in one or more lists Here, we explain how to plot data which has been calculated before and which is contained in a list. ... +available in a list. ... The procedure is quite the same as for plotting a data file or a function in the above examples. The difference is that we here use a `graph.data.points` instance to the `plot` method of the graph. It takes a list of data points which come as tuples. You will have to say something like `x=1, y=2` to specify which entry in your tuples is to be used on which axis. +the above examples. It differs in that we use an instance of +`graph.data.values` or `graph.data.points` in the `plot` method of the graph. +The choice of one or the other variant depends on convenience and how the data +has been generated: In `graph.data.values` the coordinate values are provided +as individual lists. Alternatively, `graph.data.points` takes a list of data +points which come as coordinate tuples. You will then have to say something +like `x=1, y=2` to specify which entry in your tuples is to be used on which +axis. Similarly to the plotting of a data file, the default plotting style is with symbols. This appears to be the the natural choice, since the data is of discrete nature. +Similarly to the plotting of a data file, the default plotting style here are +symbols. Caution: This feature has been renamed between versions 0.9 and 0.10. The old name in version 0.9 and before was `graph.data.list`. +Caution: This feature has been renamed/introduced between versions 0.9 and +0.10. In versions 0.9 and before the functionality of `graph.data.points` was +provided by `graph.data.list`. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. 