import matplotlib pyplot as pyplot set up the data labels ('python''scala'' #''java''php'index ( provides locations on axis sizes [ set up the bar chart pyplot bar(indexsizestick_label=labelsconfigure the layout pyplot ylabel('usage'pyplot xlabel('programming languages'display the chart pyplot show(the chart is constructed such that the lengths of the different bars are proportional to the size of the category they represent the -axis represents the different categories and so has no scale in order to emphasise the fact that the categories are discretea gap is left between the bars on the -axis the -axis does have scale and this indicates the units of measurement horizontal bar charts bar charts are normally drawn so that the bars are vertical which means that the taller the barthe larger the category howeverit is also possible to draw bar charts so that the bars are horizontal which means that the longer the barthe larger the category this is particularly effective way of presenting large number of different categories when there is insufficient space to fit all the columns required for vertical bar chart across the page in matplotlib the pyplot barh(function can be used to generate horizontal bar chart