Creating a Graph, Part 2

This page will start with the script graph.py, and create a new graph2.py to add some additional features.

graph.py makes a simple graph with X and Y axes, labels for the axes, and a title. With graph2.py we will add the ability to assign a scale to the axes, make user-defined tick marks, and then give some feed back about the typographic features of this graph.

New requestors

The first asks for the value for the total X axis in the units of the graph (no need to name the units here), which we need to convert to an integer. The second asks for the number of units between tick marks on the X axis scale.

From this we can calculate a typographic scale for our graph, using the fact that we have set the width of the graph with the variable xaxis:

You might be thinking at this point, "Who would want to mess around with a calculator for data points?" The answer is that Scribus will calculate for you.

For example, let's say you have a data point (150, 5345) in the above graph. Make a small rectangle shape or circle, adjust size to 2pts × 2pts. In the X-Pos requestor in the XYZ tab, delete the contents, enter values for xorigin+xdata*xscale, or in this case, 150+150*1.096, then press Tab -- the value is calculated, the point shifted, and then Y-Pos highlighted. Then for Y-Pos, yorigin-ydata*yscale, or 450-5345*0.035, then Tab (or Return). The shape goes to X-Pos = 314.40, Y-Pos = 262.92 -- simple.

For more data points, just Item > Duplicate, then enter the formula for the next point. Lock your points so they don't accidentally get moved.