prevent double call of _cleanup, which harms usefiles (and is a bad idea in general)
[PyX.git] / test / functional / test_histogram.py
blobbec235fa0eff50682b6372804d545afff7150423
1 import random
2 import sys; sys.path[:0] = ["../.."]
3 from pyx import *
5 d1 = graph.data.points([(1.5, 1, 0.3),
6 (3, 0.5, 0.5),
7 (4, 0.5, 0.2),
8 (None, 0.5, 0.8),
9 (6, None, 0.9),
10 (7, 0.5, None),
11 (10, 2.5, 0.8),
12 (13, 0.5, -0.2),
13 (14, 0.5, 0.4)], x=1, dx=2, y=3)
14 d2 = graph.data.data(d1, y="x", dy="dx", x="y", copy=0)
15 d3 = graph.data.points([(1, 0.3),
16 (2, 0.5),
17 (3, -0.2),
18 (4, 0.8),
19 (5, 0.5)], x=1, y=2)
20 d4 = graph.data.data(d3, y="x", x="y")
22 c = canvas.canvas()
24 def draw(d, xpos, ypos, autohistogramaxisindex=0, autohistogrampointpos=0, fillablesteps=0, **kwargs):
25 g = c.insert(graph.graphxy(xpos, ypos, width=8, **kwargs))
26 g.plot(d, [graph.style.histogram(fillable=1, steps=fillablesteps, lineattrs=[color.rgb.green, style.linewidth.THIck, deco.filled([color.rgb.blue])],
27 autohistogramaxisindex=autohistogramaxisindex, autohistogrampointpos=autohistogrampointpos)])
28 g.plot(d, [graph.style.histogram(steps=1, lineattrs=[color.rgb.red, style.linewidth.Thick],
29 autohistogramaxisindex=autohistogramaxisindex, autohistogrampointpos=autohistogrampointpos)])
30 g.plot(d, [graph.style.histogram(steps=0,
31 autohistogramaxisindex=autohistogramaxisindex, autohistogrampointpos=autohistogrampointpos)])
33 draw(d1, 10, 0)
34 draw(d2, 0, 0)
35 draw(d3, 10, 7, autohistogramaxisindex=0, autohistogrampointpos=0)
36 draw(d4, 0, 7, autohistogramaxisindex=1, autohistogrampointpos=1)
37 draw(d1, 10, 14, x=graph.axis.lin(min=3, max=14), y=graph.axis.lin(min=-0.1, max=0.45))
38 draw(d2, 0, 14, y=graph.axis.lin(min=3, max=14), x=graph.axis.lin(min=-0.1, max=0.45))
39 draw(d1, 10, 21, fillablesteps=1, x=graph.axis.lin(min=3, max=14), y=graph.axis.lin(min=-0.1, max=0.45))
40 draw(d2, 0, 21, fillablesteps=1, y=graph.axis.lin(min=3, max=14), x=graph.axis.lin(min=-0.1, max=0.45))
41 c.writeEPSfile("test_histogram")
42 c.writePDFfile("test_histogram")
43 c.writeSVGfile("test_histogram")