~mrooney/cairoplot/label-formatters

« back to all changes in this revision

Viewing changes to trunk/tests.py

  • Committer: Rodrigo Moreira Araujo
  • Date: 2009-03-11 00:29:17 UTC
  • Revision ID: rodrigo@scrooge-20090311002917-3warch0r3wek5u8l
CairoPlot.py: 
 - Value labels above the bars are now possible through the display_values attribute.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
import cairoplot
6
6
 
7
 
test_vertical_bar_plot = 0
8
 
test_horizontal_bar_plot = 0
 
7
test_vertical_bar_plot = 1
 
8
test_horizontal_bar_plot = 1
9
9
test_scatter_plot = 0
10
10
test_donut_plot = 0
11
11
test_dot_line_plot = 0
19
19
    data = { 'teste00' : [27], 'teste01' : [10], 'teste02' : [18], 'teste03' : [5], 'teste04' : [1], 'teste05' : [22] }
20
20
    cairoplot.vertical_bar_plot ( 'vbar_0_dictionary', data, 400, 300, border = 20, grid = True, rounded_corners = True )
21
21
 
 
22
    #Display values
 
23
    data = { 'teste00' : [27], 'teste01' : [10], 'teste02' : [18], 'teste03' : [5], 'teste04' : [1], 'teste05' : [22] }
 
24
    cairoplot.vertical_bar_plot ( 'vbar_0_dictionary', data, 400, 300, border = 20, display_values = True, grid = True, rounded_corners = True )
 
25
 
22
26
    #Using default, rounded corners and 3D visualization
23
27
    data = [ [0, 3, 11], [8, 9, 21], [13, 10, 9], [2, 30, 8] ]
24
28
    colors = [ (1,0.2,0), (1,0.7,0), (1,1,0) ]
25
29
    cairoplot.vertical_bar_plot ( 'vbar_1_default', data, 400, 300, border = 20, grid = True, rounded_corners = False, colors = "yellow_orange_red" )
26
 
    cairoplot.vertical_bar_plot ( 'vbar_2_rounded', data, 400, 300, border = 20, grid = True, rounded_corners = True, colors = colors )
 
30
    cairoplot.vertical_bar_plot ( 'vbar_2_rounded', data, 400, 300, border = 20, display_values = True, grid = True, rounded_corners = True, colors = colors )
27
31
    cairoplot.vertical_bar_plot ( 'vbar_3_3D', data, 400, 300, border = 20, grid = True, three_dimension = True, colors = colors )
28
32
 
29
33
    #Mixing groups and columns
48
52
    data = [ [6, 4, 10], [8, 9, 3], [1, 10, 9], [2, 7, 11] ]
49
53
    colors = [ (1,0.2,0), (1,0.7,0), (1,1,0) ]
50
54
    x_labels = ["teste1", "teste2", "testegrande3", "testegrande4"]
51
 
    cairoplot.vertical_bar_plot ( 'vbar_10_stack', data, 400, 300, border = 20, grid = True, rounded_corners = True, stack = True, 
 
55
    cairoplot.vertical_bar_plot ( 'vbar_10_stack', data, 400, 300, border = 20, display_values = True, grid = True, rounded_corners = True, stack = True, 
52
56
                                  x_labels = x_labels, colors = colors )
53
57
 
54
58
 
55
59
if test_horizontal_bar_plot:
56
60
    #Passing a dictionary
57
61
    data = { 'teste00' : [27], 'teste01' : [10], 'teste02' : [18], 'teste03' : [5], 'teste04' : [1], 'teste05' : [22] }
58
 
    cairoplot.horizontal_bar_plot ( 'hbar_0_dictionary', data, 400, 300, border = 20, grid = True, rounded_corners = True )
 
62
    cairoplot.horizontal_bar_plot ( 'hbar_0_dictionary', data, 400, 300, border = 20, display_values = True, grid = True, rounded_corners = True )
59
63
 
60
64
    #Using default, rounded corners and 3D visualization
61
65
    data = [ [0, 3, 11], [8, 9, 21], [13, 10, 9], [2, 30, 8] ]
62
66
    colors = [ (1,0.2,0), (1,0.7,0), (1,1,0) ]
63
67
    cairoplot.horizontal_bar_plot ( 'hbar_1_default', data, 400, 300, border = 20, grid = True, rounded_corners = False, colors = "yellow_orange_red" )
64
 
    cairoplot.horizontal_bar_plot ( 'hbar_2_rounded', data, 400, 300, border = 20, grid = True, rounded_corners = True, colors = colors )
 
68
    cairoplot.horizontal_bar_plot ( 'hbar_2_rounded', data, 400, 300, border = 20, display_values = True, grid = True, rounded_corners = True, colors = colors )
65
69
 
66
70
    #Mixing groups and columns
67
71
    data = [ [1], [2], [3,4], [4], [5], [6], [7], [8], [9], [10] ]
74
78
    cairoplot.horizontal_bar_plot ( 'hbar_5_no_labels', data, 600, 200, border = 20, grid = True )
75
79
    cairoplot.horizontal_bar_plot ( 'hbar_6_x_labels', data, 600, 200, border = 20, grid = True, x_labels = x_labels )
76
80
    cairoplot.horizontal_bar_plot ( 'hbar_7_y_labels', data, 600, 200, border = 20, grid = True, y_labels = y_labels )
77
 
    cairoplot.horizontal_bar_plot ( 'hbar_8_hy_labels', data, 600, 200, border = 20, grid = True, x_labels = x_labels, y_labels = y_labels )
 
81
    cairoplot.horizontal_bar_plot ( 'hbar_8_hy_labels', data, 600, 200, border = 20, display_values = True, grid = True, x_labels = x_labels, y_labels = y_labels )
78
82
    
79
83
    #Large data set
80
84
    data = [[10*random.random()] for x in range(25)]
85
89
    data = [ [6, 4, 10], [8, 9, 3], [1, 10, 9], [2, 7, 11] ]
86
90
    colors = [ (1,0.2,0), (1,0.7,0), (1,1,0) ]
87
91
    y_labels = ["teste1", "teste2", "testegrande3", "testegrande4"]
88
 
    cairoplot.horizontal_bar_plot ( 'hbar_10_stack', data, 400, 300, border = 20, grid = True, rounded_corners = True, stack = True, 
 
92
    cairoplot.horizontal_bar_plot ( 'hbar_10_stack', data, 400, 300, border = 20, display_values = True, grid = True, rounded_corners = True, stack = True, 
89
93
                                    y_labels = y_labels, colors = colors )
90
94
 
91
95
if test_donut_plot :