## PyPlotter - A Python/Jython Graph Plotting Package. Manual |

Contents |

1 Introduction |

2 License |

3 Screenshots |

4 Quick Tutorial |

4.1 Example 1: Plotting a Graph |

4.2 Example 2: Plotting a simplex diagram |

5 Reference |

6 Implementing a new device driver for PyPlotter |

In order to see the results of this example, either run the file “Example1.py” from the PyPlotter directory or enter the following lines at the python command prompt.

1: import math 2: from PyPlotter import tkGfx as GfxDriver # 'awtGfx' for jython 3: from PyPlotter import Graph, Gfx 4: 5: gfx = GfxDriver.Window(title="Function Plotter") 6: gr = Graph.Cartesian(gfx, -4.0, -2.0, 4.0, 2.0) 7: gr.addPen("sin(x)", Gfx.RED_PEN) 8: for x in gr.xaxisSteps(-4.0, 4.0): 9: gr.addValue("sin(x)", x, math.sin(x)) 10: gfx.waitUntilClosed()

Thats all! If everything went right you should have seen a nice sine
curve on your display. Here is an explanation of what the program does.
Line 5 opens a window for graphical output. Then a new cartesian graph
is being created in this window. In line 7 a new pen is added to the
graph. Before you can draw anything onto the graph, you have to add
one or more pens. Every pen is identified by its unique name. By default
the graph as a caption where all pens are listed by their names. To
actually draw something on the graph, you have to add one or more coordinate
pairs to the graph with a given pen. The coordinate pairs of a pen
will then be connected with a continuous line in the order they where
added to the graph. This is done in line 8 and 9. In line 8 the method
`xaxisSteps` is called, which returns a list of x values for
a given range, each of which corresponds to exactly one pixel on the
screen.

Since Version 0.8.7 of PyPlotter the same can be done even simpler:

1: import math 2: from PyPlotter import Graph 3: gr = Graph.Cartesian(Graph.AUTO_GFX, -4.0, -2.0, 4.0, 2.0) 4: for x in gr.xaxisSteps(-4.0, 4.0): 5: gr.addValue("sin(x)", x, math.sin(x)) 6: gr.gfx.waitUntilClosed()