h_simple.Fill(random.gauss(4, 3)) # easily set visual attributes h_simple.linecolor = 'blue' h_simple.fillcolor = 'green' h_simple.fillstyle = '/' # attributes may be accessed in the same way print h_simple.name print h_simple.title print h_simple.markersize # plot canvas = Canvas(width=700, height=500) canvas.SetLeftMargin(0.15) canvas.SetBottomMargin(0.15) canvas.SetTopMargin(0.10) canvas.SetRightMargin(0.05) h_simple.Draw() legend = Legend(1) legend.AddEntry(h_simple, style='F') legend.Draw() canvas.Modified() canvas.Update() # 2D and 3D histograms are handled in the same way # the constructor arguments are repetitions of #bins, left bound, right bound. h2d = Hist2D(10, 0, 1, 50, -40, 10, name='2d hist') h3d = Hist3D(3, -1, 4, 10, -1000, -200, 2, 0, 1, name='3d hist') # variable-width bins may be created by passing the bin edges directly:
if plots_paths.get(topLevelPath, {}): break topLevelPath = os.path.dirname(topLevelPath) # top level path empty so break if not topLevelPath: break plots_path = plots_paths.get(topLevelPath, {}) # create new canvas canvasConfigs = copy.copy(plots_config.get('canvas', {})) canvasConfigs.update(plots_path.get('canvas', {})) canvas = Canvas(canvasConfigs.get('width', 500), canvasConfigs.get('height', 500)) canvas.SetRightMargin(canvasConfigs.get('rightmargin', 0.1)) canvas.SetBottomMargin(canvasConfigs.get('bottommargin', 0.2)) canvas.SetLeftMargin(canvasConfigs.get('leftmargin', 0.2)) if canvasConfigs.get('logy', False) == True: canvas.set_logy() # create a legend (an entry for each group) legendConfigs = copy.copy(plots_config.get('legend', {})) legendConfigs.update(plots_path.get('legend', {})) legend_numColumns = legendConfigs.pop('num columns', 1) legend = Legend(len(h), **legendConfigs) legend.SetNColumns(legend_numColumns) # scale the histograms before doing anything else for hgroup in h: if groups.get(hgroup.group).get('do not scale me', False):