9
9
test_dot_line_plot = 1
10
test_function_plot = 0
10
test_function_plot = 1
16
16
#Passing a dictionary
17
17
data = { 'teste00' : [27], 'teste01' : [10], 'teste02' : [18], 'teste03' : [5], 'teste04' : [1], 'teste05' : [22] }
18
CairoPlot.bar_plot ( 'bar_0_dictionary', data, 400, 300, border = 20, grid = True, rounded_corners = True )
18
cairoplot.bar_plot ( 'bar_0_dictionary', data, 400, 300, border = 20, grid = True, rounded_corners = True )
20
20
#Using default, rounded corners and 3D visualization
21
21
data = [ [0, 3, 11], [8, 9, 21], [13, 10, 9], [2, 30, 8] ]
22
22
colors = [ (1,0.2,0), (1,0.7,0), (1,1,0) ]
23
CairoPlot.bar_plot ( 'bar_1_default', data, 400, 300, border = 20, grid = True, rounded_corners = False, colors = "yellow_orange_red" )
24
CairoPlot.bar_plot ( 'bar_2_rounded', data, 400, 300, border = 20, grid = True, rounded_corners = True, colors = colors )
25
CairoPlot.bar_plot ( 'bar_3_3D', data, 400, 300, border = 20, grid = True, three_dimension = True, colors = colors )
23
cairoplot.bar_plot ( 'bar_1_default', data, 400, 300, border = 20, grid = True, rounded_corners = False, colors = "yellow_orange_red" )
24
cairoplot.bar_plot ( 'bar_2_rounded', data, 400, 300, border = 20, grid = True, rounded_corners = True, colors = colors )
25
cairoplot.bar_plot ( 'bar_3_3D', data, 400, 300, border = 20, grid = True, three_dimension = True, colors = colors )
27
27
#Mixing groups and columns
28
28
data = [ [1], [2], [3,4], [4], [5], [6], [7], [8], [9], [10] ]
29
CairoPlot.bar_plot ( 'bar_4_group', data, 400, 300, border = 20, grid = True )
29
cairoplot.bar_plot ( 'bar_4_group', data, 400, 300, border = 20, grid = True )
31
31
#Using no labels, horizontal and vertical labels
32
32
data = [[3,4], [4,8], [5,3], [9,1]]
33
33
y_labels = [ "line1", "line2", "line3", "line4", "line5", "line6" ]
34
34
x_labels = [ "group1", "group2", "group3", "group4" ]
35
CairoPlot.bar_plot ( 'bar_5_no_labels', data, 600, 200, border = 20, grid = True )
36
CairoPlot.bar_plot ( 'bar_6_x_labels', data, 600, 200, border = 20, grid = True, x_labels = x_labels )
37
CairoPlot.bar_plot ( 'bar_7_y_labels', data, 600, 200, border = 20, grid = True, y_labels = y_labels )
38
CairoPlot.bar_plot ( 'bar_8_hy_labels', data, 600, 200, border = 20, grid = True, x_labels = x_labels, y_labels = y_labels )
35
cairoplot.bar_plot ( 'bar_5_no_labels', data, 600, 200, border = 20, grid = True )
36
cairoplot.bar_plot ( 'bar_6_x_labels', data, 600, 200, border = 20, grid = True, x_labels = x_labels )
37
cairoplot.bar_plot ( 'bar_7_y_labels', data, 600, 200, border = 20, grid = True, y_labels = y_labels )
38
cairoplot.bar_plot ( 'bar_8_hy_labels', data, 600, 200, border = 20, grid = True, x_labels = x_labels, y_labels = y_labels )
40
40
if test_donut_plot :
41
41
#Define a new backgrond
46
46
data = {"john" : 700, "mary" : 100, "philip" : 100 , "suzy" : 50, "yman" : 50}
47
47
#Default plot, gradient and shadow, different background
48
CairoPlot.donut_plot( "donut_1_default", data, 600, 400, inner_radius = 0.3 )
49
CairoPlot.donut_plot( "donut_2_gradient_shadow", data, 600, 400, gradient = True, shadow = True, inner_radius = 0.3 )
50
CairoPlot.donut_plot( "donut_3_background", data, 600, 400, background = background, gradient = True, shadow = True, inner_radius = 0.3 )
48
cairoplot.donut_plot( "donut_1_default", data, 600, 400, inner_radius = 0.3 )
49
cairoplot.donut_plot( "donut_2_gradient_shadow", data, 600, 400, gradient = True, shadow = True, inner_radius = 0.3 )
50
cairoplot.donut_plot( "donut_3_background", data, 600, 400, background = background, gradient = True, shadow = True, inner_radius = 0.3 )
52
52
if test_dot_line_plot:
54
54
data = [ 0, 1, 3.5, 8.5, 9, 0, 10, 10, 2, 1 ]
55
CairoPlot.dot_line_plot( "dot_line_1_default", data, 400, 300, border = 50, axis = True, grid = True,
55
cairoplot.dot_line_plot( "dot_line_1_default", data, 400, 300, border = 50, axis = True, grid = True,
56
56
x_title = "x axis", y_title = "y axis" )
59
59
data = { "john" : [-5, -2, 0, 1, 3], "mary" : [0, 0, 3, 5, 2], "philip" : [-2, -3, -4, 2, 1] }
60
60
x_labels = [ "jan/2008", "feb/2008", "mar/2008", "apr/2008", "may/2008" ]
61
61
y_labels = [ "very low", "low", "medium", "high", "very high" ]
62
CairoPlot.dot_line_plot( "dot_line_2_dictionary_labels", data, 400, 300, x_labels = x_labels,
62
cairoplot.dot_line_plot( "dot_line_2_dictionary_labels", data, 400, 300, x_labels = x_labels,
63
63
y_labels = y_labels, axis = True, grid = True,
64
64
x_title = "x axis", y_title = "y axis", series_legend=True )
67
67
data = { "john" : [10, 10, 10, 10, 30], "mary" : [0, 0, 3, 5, 15], "philip" : [13, 32, 11, 25, 2] }
68
68
x_labels = [ "jan/2008", "feb/2008", "mar/2008", "apr/2008", "may/2008" ]
69
CairoPlot.dot_line_plot( 'dot_line_3_series_legend', data, 400, 300, x_labels = x_labels,
69
cairoplot.dot_line_plot( 'dot_line_3_series_legend', data, 400, 300, x_labels = x_labels,
70
70
axis = True, grid = True, series_legend = True )
72
72
if test_function_plot :
74
74
data = lambda x : x**2
75
CairoPlot.function_plot( 'function_1_default', data, 400, 300, grid = True, x_bounds=(-10,10), step = 0.1 )
75
cairoplot.function_plot( 'function_1_default', data, 400, 300, grid = True, x_bounds=(-10,10), step = 0.1 )
78
78
data = lambda x : math.sin(0.1*x)*math.cos(x)
79
CairoPlot.function_plot( 'function_2_discrete', data, 800, 300, discrete = True, dots = True, grid = True, x_bounds=(0,80),
79
cairoplot.function_plot( 'function_2_discrete', data, 800, 300, discrete = True, dots = True, grid = True, x_bounds=(0,80),
80
80
x_title = "t (s)", y_title = "sin(0.1*x)*cos(x)")
83
83
data = lambda x : [1,2,3,4,5][x]
84
84
x_labels = [ "4", "3", "2", "1", "0" ]
85
CairoPlot.function_plot( 'function_3_labels', data, 400, 300, discrete = True, dots = True, grid = True, x_labels = x_labels, x_bounds=(0,4), step = 1 )
85
cairoplot.function_plot( 'function_3_labels', data, 400, 300, discrete = True, dots = True, grid = True, x_labels = x_labels, x_bounds=(0,4), step = 1 )
87
87
#Multiple functions
88
88
data = [ lambda x : 1, lambda y : y**2, lambda z : -z**2 ]
89
89
colors = [ (1.0, 0.0, 0.0 ), ( 0.0, 1.0, 0.0 ), ( 0.0, 0.0, 1.0 ) ]
90
CairoPlot.function_plot( 'function_4_multi_functions', data, 400, 300, grid = True, series_colors = colors, step = 0.1 )
90
cairoplot.function_plot( 'function_4_multi_functions', data, 400, 300, grid = True, series_colors = colors, step = 0.1 )
92
92
if test_gantt_chart :
108
108
data = {"orcs" : 100, "goblins" : 230, "elves" : 50 , "demons" : 43, "humans" : 332}
109
CairoPlot.pie_plot( "pie_1_default", data, 600, 400 )
110
CairoPlot.pie_plot( "pie_2_gradient_shadow", data, 600, 400, gradient = True, shadow = True )
111
CairoPlot.pie_plot( "pie_3_background", data, 600, 400, background = background, gradient = True, shadow = True )
109
cairoplot.pie_plot( "pie_1_default", data, 600, 400 )
110
cairoplot.pie_plot( "pie_2_gradient_shadow", data, 600, 400, gradient = True, shadow = True )
111
cairoplot.pie_plot( "pie_3_background", data, 600, 400, background = background, gradient = True, shadow = True )
113
113
if test_scatter_plot:
115
115
data = [ (-2,10), (0,0), (0,15), (1,5), (2,0), (3,-10), (3,5) ]
116
CairoPlot.scatter_plot ( 'cross_1_default', data = data, width = 500, height = 500, border = 20, axis = True, grid = True )
116
cairoplot.scatter_plot ( 'cross_1_default', data = data, width = 500, height = 500, border = 20, axis = True, grid = True )
118
118
data = [(-1, -16, 12), (-12, 17, 11), (-4, 6, 5), (4, -20, 12), (13, -3, 21), (7, 14, 20), (-11, -2, 18), (19, 7, 18), (-10, -19, 15),
119
119
(-17, -2, 6), (-9, 4, 10), (14, 11, 16), (13, -11, 18), (20, 20, 16), (7, -8, 15), (-16, 17, 16), (16, 9, 9), (-3, -13, 25),
121
121
(17, -15, 25), (-2, -8, 5), (5, 20, 20), (18, 20, 23), (-20, -16, 17), (-19, -2, 9), (-11, 19, 18), (17, 16, 12), (-5, -20, 15),
122
122
(-20, -13, 10), (-3, 5, 20), (-1, 13, 17), (-11, -9, 11)]
123
123
colors = [ (0,0,0,0.25), (1,0,0,0.75) ]
124
CairoPlot.scatter_plot ( 'cross_2_variable_radius', data = data, width = 500, height = 500, border = 20,
124
cairoplot.scatter_plot ( 'cross_2_variable_radius', data = data, width = 500, height = 500, border = 20,
125
125
axis = True, discrete = True, dots = 2, grid = True,
126
126
x_title = "x axis", y_title = "y axis", circle_colors = colors )
134
134
ery = [5*random.random() for x in t]
135
135
data = {"exp" : [t,f], "cos" : [t,g], "sin" : [t,h]}
136
136
series_colors = [ (1,0,0), (0,0,0), (0,0,1) ]
137
CairoPlot.scatter_plot ( 'cross_r_exponential', data = data, errorx = [erx,erx], errory = [ery,ery], width = 800, height = 600, border = 20,
137
cairoplot.scatter_plot ( 'cross_r_exponential', data = data, errorx = [erx,erx], errory = [ery,ery], width = 800, height = 600, border = 20,
138
138
axis = True, discrete = False, dots = 5, grid = True,
139
139
x_title = "t", y_title = "f(t) g(t)", series_legend=True, series_colors = series_colors )
143
143
data = [1,2,3,4,5,6,7,8,9,10,11,12,13,14]
144
CairoPlot.bar_plot ( 'bar_color_themes', data, 400, 300, border = 20, grid = True, colors="rainbow" )
144
cairoplot.bar_plot ( 'bar_color_themes', data, 400, 300, border = 20, grid = True, colors="rainbow" )
146
146
data = [ lambda x : 1, lambda y : y**2, lambda z : -z**2 ]
147
CairoPlot.function_plot( 'function_color_themes', data, 400, 300, grid = True, series_colors = ["red", "orange", "yellow"], step = 0.1 )
147
cairoplot.function_plot( 'function_color_themes', data, 400, 300, grid = True, series_colors = ["red", "orange", "yellow"], step = 0.1 )
149
149
#Scatter x DotLine
150
150
t = [x*0.1 for x in range(0,40)]