<commit_before>import pylab
from matplotlib import pyplot
from matplotlib.transforms import Affine2D, IdentityTransform
from PlotInfo import *
from Bar import *
from StackedBars import *
import sys

class ClusteredBars(PlotInfo):
    """
    A clustered bar chart consisting of multiple series of bars
    with the same X axis values.
    """
    def __init__(self):
        PlotInfo.__init__(self, "clustered bar")
        
        self.bars = []
        self.spacing = 0
        self.width = 0.8
        
    def add(self, bar):
        if not isinstance(bar, Bar) and not isinstance(bar, StackedBars):
            print >>sys.stderr, "Can only add Bars to a ClusteredBars"
            sys.exit(1)
        
        self.bars.append(bar)
    
    def getXLabelLocations(self):
        labelLocations = []
        clusterWidth = sum([bar.width for bar in self.bars])

        for x in self.bars[0].xValues:
            labelLocations.append((clusterWidth + self.spacing) * x +\
                                   clusterWidth / 2.0)

        return labelLocations
    
    def draw(self, axis, transform=None):
        if self.xTickLabels is not None:
            self.xTickLabelPoints = self.getXLabelLocations()
            if len(self.xTickLabelPoints) != len(self.xTickLabels):
                print >>sys.stderr, "Number of clustered bar labels doesn't match number of points"
                print >>sys.stderr, "Labels: %s" % (self.xTickLabels)
                print >>sys.stderr, "Points: %s" % (self.xTickLabelPoints)
                sys.exit(1)

        PlotInfo.draw(self, axis)

        return self._draw(axis, transform)
        

    def _draw(self, axis, transform=None):
        numBars = len(self.bars)<commit_msg>Fixing clustered bar label positioning.<commit_after>import pylab
from matplotlib import pyplot
from matplotlib.transforms import Affine2D, IdentityTransform
from PlotInfo import *
from Bar import *
from StackedBars import *
import sys

class ClusteredBars(PlotInfo):
    """
    A clustered bar chart consisting of multiple series of bars
    with the same X axis values.
    """
    def __init__(self):
        PlotInfo.__init__(self, "clustered bar")
        
        self.bars = []
        self.spacing = 0
        self.width = 1
        
    def add(self, bar):
        if not isinstance(bar, Bar) and not isinstance(bar, StackedBars):
            print >>sys.stderr, "Can only add Bars to a ClusteredBars"
            sys.exit(1)
        bar.width = self.width
        self.bars.append(bar)
    
    def getXLabelLocations(self):
        labelLocations = []
        clusterWidth = sum([bar.width for bar in self.bars])
        for x in self.bars[0].xValues:
            labelLocations.append((clusterWidth + self.spacing) * float(x) - (self.width / 2.0) + clusterWidth / 2.0)
            
        return labelLocations
    
    def draw(self, axis, transform=None):
        if self.xTickLabels is not None:
            self.xTickLabelPoints = self.getXLabelLocations()
            if len(self.xTickLabelPoints) != len(self.xTickLabels):
                print >>sys.stderr, "Number of clustered bar labels doesn't match number of points"
                print >>sys.stderr, "Labels: %s" % (self.xTickLabels)
                print >>sys.stderr, "Points: %s" % (self.xTickLabelPoints)
                sys.exit(1)

        PlotInfo.draw(self, axis)

        return self._draw(axis, transform)
        

    def _draw(self, axis, transform=None):
        numBars = len(self.bars)
{'fraction_non_alphanumeric': 0.09626886926801481, 'fraction_numerical': 0.005411563657077755, 'mean_word_length': 2.1985428051001823, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3167964', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1003, 'n_words': 287}