barchart.py (2119:f0de10227ae5) barchart.py (2160:d851e177e4c6)
1# Copyright (c) 2005-2006 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 137 unchanged lines hidden (view full) ---

146 self.metaaxes = self.figure.add_axes(self.figure_size, axisbg=color, frameon=False)
147 for tick in self.metaaxes.xaxis.majorTicks:
148 tick.tick1On = False
149 tick.tick2On = False
150 self.metaaxes.set_yticklabels([])
151 self.metaaxes.set_yticks([])
152 size = [0] * 4
153 size[0] = self.figure_size[0]
1# Copyright (c) 2005-2006 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 137 unchanged lines hidden (view full) ---

146 self.metaaxes = self.figure.add_axes(self.figure_size, axisbg=color, frameon=False)
147 for tick in self.metaaxes.xaxis.majorTicks:
148 tick.tick1On = False
149 tick.tick2On = False
150 self.metaaxes.set_yticklabels([])
151 self.metaaxes.set_yticks([])
152 size = [0] * 4
153 size[0] = self.figure_size[0]
154 size[1] = self.figure_size[1] + .05
154 size[1] = self.figure_size[1] + .12
155 size[2] = self.figure_size[2]
155 size[2] = self.figure_size[2]
156 size[3] = self.figure_size[3] - .05
156 size[3] = self.figure_size[3] - .12
157 self.axes = self.figure.add_axes(size)
158 outer_axes = self.metaaxes
159 inner_axes = self.axes
160 else:
161 self.axes = self.figure.add_axes(self.figure_size)
162 outer_axes = self.axes
163 inner_axes = self.axes
164
165 bars_in_group = len(self.chartdata)
157 self.axes = self.figure.add_axes(size)
158 outer_axes = self.metaaxes
159 inner_axes = self.axes
160 else:
161 self.axes = self.figure.add_axes(self.figure_size)
162 outer_axes = self.axes
163 inner_axes = self.axes
164
165 bars_in_group = len(self.chartdata)
166 if bars_in_group < 5:
167 width = 1.0 / ( bars_in_group + 1)
168 center = width / 2
169 else:
170 width = .8 / bars_in_group
171 center = .1
172
166
167 width = 1.0 / ( bars_in_group + 1)
168 center = width / 2
169
173 bars = []
174 for i,stackdata in enumerate(self.chartdata):
175 bottom = array([0.0] * len(stackdata[0]), Float)
176 stack = []
177 for j,bardata in enumerate(stackdata):
178 bardata = array(bardata)
179 ind = arange(len(bardata)) + i * width + center
180 bar = self.axes.bar(ind, bardata, width, bottom=bottom,
181 color=colors[i][j])
170 bars = []
171 for i,stackdata in enumerate(self.chartdata):
172 bottom = array([0.0] * len(stackdata[0]), Float)
173 stack = []
174 for j,bardata in enumerate(stackdata):
175 bardata = array(bardata)
176 ind = arange(len(bardata)) + i * width + center
177 bar = self.axes.bar(ind, bardata, width, bottom=bottom,
178 color=colors[i][j])
182 if dim != 1:
179 if self.xsubticks is not None:
183 self.metaaxes.bar(ind, [0] * len(bardata), width)
184 stack.append(bar)
185 bottom += bardata
186 bars.append(stack)
187
188 if self.xlabel is not None:
189 outer_axes.set_xlabel(self.xlabel)
190

--- 11 unchanged lines hidden (view full) ---

202
203 if self.xticks is not None:
204 outer_axes.set_xticks(arange(cshape[2]) + .5)
205 outer_axes.set_xticklabels(self.xticks)
206
207 if self.xsubticks is not None:
208 inner_axes.set_xticks(arange((cshape[0] + 1)*cshape[2])*width + 2*center)
209 self.xsubticks.append('')
180 self.metaaxes.bar(ind, [0] * len(bardata), width)
181 stack.append(bar)
182 bottom += bardata
183 bars.append(stack)
184
185 if self.xlabel is not None:
186 outer_axes.set_xlabel(self.xlabel)
187

--- 11 unchanged lines hidden (view full) ---

199
200 if self.xticks is not None:
201 outer_axes.set_xticks(arange(cshape[2]) + .5)
202 outer_axes.set_xticklabels(self.xticks)
203
204 if self.xsubticks is not None:
205 inner_axes.set_xticks(arange((cshape[0] + 1)*cshape[2])*width + 2*center)
206 self.xsubticks.append('')
210 inner_axes.set_xticklabels(self.xsubticks * cshape[2], fontsize=8)
207 inner_axes.set_xticklabels(self.xsubticks * cshape[2], fontsize=7, rotation=90)
211
212 if self.legend is not None:
213 if dim == 1:
214 lbars = bars[0][0]
215 if dim == 2:
216 lbars = [ bars[i][0][0] for i in xrange(len(bars))]
217 if dim == 3:
218 number = len(bars[0])

--- 57 unchanged lines hidden (view full) ---

276 chart1 = BarChart()
277 chart1.data = data
278
279 chart1.xlabel = 'Benchmark'
280 chart1.ylabel = 'Bandwidth (GBps)'
281 chart1.legend = [ 'x%d' % x for x in xrange(myshape[-1]) ]
282 chart1.xticks = [ 'xtick%d' % x for x in xrange(myshape[0]) ]
283 chart1.title = 'this is the title'
208
209 if self.legend is not None:
210 if dim == 1:
211 lbars = bars[0][0]
212 if dim == 2:
213 lbars = [ bars[i][0][0] for i in xrange(len(bars))]
214 if dim == 3:
215 number = len(bars[0])

--- 57 unchanged lines hidden (view full) ---

273 chart1 = BarChart()
274 chart1.data = data
275
276 chart1.xlabel = 'Benchmark'
277 chart1.ylabel = 'Bandwidth (GBps)'
278 chart1.legend = [ 'x%d' % x for x in xrange(myshape[-1]) ]
279 chart1.xticks = [ 'xtick%d' % x for x in xrange(myshape[0]) ]
280 chart1.title = 'this is the title'
284 chart1.figure_size = [0.1, 0.2, 0.7, 0.85 ]
285 if len(myshape) > 2:
286 chart1.xsubticks = [ '%d' % x for x in xrange(myshape[1]) ]
287 chart1.graph()
288 chart1.savefig('/tmp/test1.png')
289 chart1.savefig('/tmp/test1.ps')
290 chart1.savefig('/tmp/test1.eps')
291 chart1.savecsv('/tmp/test1.csv')
292
293 if False:
294 chart2 = BarChart()
295 chart2.data = data
296 chart2.colormap = 'gray'
297 chart2.graph()
298 chart2.savefig('/tmp/test2.png')
299 chart2.savefig('/tmp/test2.ps')
300
281 if len(myshape) > 2:
282 chart1.xsubticks = [ '%d' % x for x in xrange(myshape[1]) ]
283 chart1.graph()
284 chart1.savefig('/tmp/test1.png')
285 chart1.savefig('/tmp/test1.ps')
286 chart1.savefig('/tmp/test1.eps')
287 chart1.savecsv('/tmp/test1.csv')
288
289 if False:
290 chart2 = BarChart()
291 chart2.data = data
292 chart2.colormap = 'gray'
293 chart2.graph()
294 chart2.savefig('/tmp/test2.png')
295 chart2.savefig('/tmp/test2.ps')
296
301 pylab.myshow()
297# pylab.show()