| | 99 | def stripes(): |
| | 100 | |
| | 101 | # Set the vertical range from 0 to 100 |
| | 102 | max_y = 100 |
| | 103 | |
| | 104 | # Chart size of 200x125 pixels and specifying the range for the Y axis |
| | 105 | chart = SimpleLineChart(200, 125, y_range=[0, max_y]) |
| | 106 | |
| | 107 | # Add the chart data |
| | 108 | data = [ |
| | 109 | 32, 34, 34, 32, 34, 34, 32, 32, 32, 34, 34, 32, 29, 29, 34, 34, 34, 37, |
| | 110 | 37, 39, 42, 47, 50, 54, 57, 60, 60, 60, 60, 60, 60, 60, 62, 62, 60, 55, |
| | 111 | 55, 52, 47, 44, 44, 40, 40, 37, 34, 34, 32, 32, 32, 31, 32 |
| | 112 | ] |
| | 113 | chart.add_data(data) |
| | 114 | |
| | 115 | # Set the line colour to blue |
| | 116 | chart.set_colours(['0000FF']) |
| | 117 | |
| | 118 | # Set the vertical stripes |
| | 119 | chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2) |
| | 120 | |
| | 121 | # Set the horizonal dotted lines |
| | 122 | chart.set_grid(0, 25, 5, 5) |
| | 123 | |
| | 124 | # The Y axis labels contains 0 to 100 skipping every 25, but remove the |
| | 125 | # first number because it's obvious and gets in the way of the first X |
| | 126 | # label. |
| | 127 | left_axis = range(0, max_y + 1, 25) |
| | 128 | left_axis[0] = '' |
| | 129 | chart.set_axis_labels(Axis.LEFT, left_axis) |
| | 130 | |
| | 131 | # X axis labels |
| | 132 | chart.set_axis_labels(Axis.BOTTOM, \ |
| | 133 | ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']) |
| | 134 | |
| | 135 | chart.download('line-stripes.png') |
| | 136 | |