"Horizontal bar with red axis negative labels" import reportlab from reportlab.graphics.charts.barcharts import HorizontalBarChart from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin from reportlab.lib.colors import PCMYKColor from reportlab.graphics.charts.textlabels import RedNegativeChanger class HBarChartWRedXValueAxisNegLabels(_DrawingEditorMixin,Drawing): ''' Chart Features -------------- This is a simple horizontal barchart whose XVAlueAxis is modified to make the negative tick labels turn red. - The xValueAxis has negative tick labels coloured red. That is accomplished by changing the Label attribute customDrawChanger to be an instance of reportlab.graphics.charts.textlabels.RedNegativeChanger. This chart was built with our [Diagra](http://www.reportlab.com/software/diagra/) solution. Not the kind of chart you looking for? Go [up](..) for more charts, or to see different types of charts click on [ReportLab Charts Gallery](/chartgallery/). ''' def __init__(self,width=400,height=200,*args,**kw): Drawing.__init__(self,width,height,*args,**kw) self._add(self,HorizontalBarChart(),name='chart',validate=None,desc=None) self.chart.y = 20 self.chart.data = [(100, -110, 120, 130), (70, 80, 85, 90)] self.chart.width = self.width - 2*self.chart.x self.chart.height = self.height-self.chart.y-5 self.chart.valueAxis.labels.customDrawChanger=RedNegativeChanger() self.chart.bars[0].fillColor = PCMYKColor(100,60,0,50,alpha=85) self.chart.bars[1].fillColor = PCMYKColor(100,0,90,50,alpha=85) if __name__=="__main__": #NORUNTESTS HBarChartWRedXValueAxisNegLabels().save(formats=['pdf'],outDir='.',fnRoot=None)