In [9]:
%matplotlib inline
from IPython.display import SVG, HTML
In [16]:
html_pygal = """
<!DOCTYPE html>
<html>
  <head>
  <script type="text/javascript" src="http://kozea.github.com/pygal.js/javascripts/svg.jquery.js"></script>
  <script type="text/javascript" src="http://kozea.github.com/pygal.js/javascripts/pygal-tooltips.js"></script>
    <!-- ... -->
  </head>
  <body>
    <figure>
      {pygal_render}
    </figure>
  </body>
</html>
"""
In [22]:
import pygal
line_chart = pygal.Line()
line_chart.title = 'Browser usage evolution (in %)'
line_chart.x_labels = map(str, range(2002, 2013))
line_chart.add('Firefox', [None, None, 0, 16.6,   25,   31, 36.4, 45.5, 46.3, 42.8, 37.1])
line_chart.add('Chrome',  [None, None, None, None, None, None,    0,  3.9, 10.8, 23.8, 35.3])
line_chart.add('IE',      [85.8, 84.6, 84.7, 74.5,   66, 58.6, 54.7, 44.8, 36.2, 26.6, 20.1])
line_chart.add('Others',  [14.2, 15.4, 15.3,  8.9,    9, 10.4,  8.9,  5.8,  6.7,  6.8,  7.5])
HTML(html_pygal.format(pygal_render=line_chart.render()))
Out[22]:
Browser usage evolution (in %)0.010.020.030.040.050.060.070.080.020022003200420052006200720082009201020112012Browser usage evolution (in %)0136.484615385504.11538461516.6198.523076923408.4949793825260.561538462360.10875022431322.6325.5471579736.4384.638461538294.44172494245.5446.676923077242.02331002346.3508.715384615237.41509772342.8570.753846154257.57602653837.1632.792307692290.4095391790384.638461538504.1153846153.9446.676923077481.6503496510.8508.715384615441.90451855823.8570.753846154367.02106867535.3632.792307692300.77801685585.812.40769230779.8846153846284.674.446153846216.796933835484.7136.48461538516.220907297874.5198.52307692374.975614129566260.561538462123.93786982258.6322.6166.56383360254.7384.638461538189.02886856744.8446.676923077246.05549578636.2508.715384615295.59377801726.6570.753846154350.89232562320.1632.792307692388.33405056514.212.4076923077422.31961628115.474.4461538462415.4072978315.3136.484615385415.9833243688.9198.523076923452.8490227729260.561538462452.27299623510.4322.6444.2086247098.9384.638461538452.8490227725.8446.676923077470.7058454376.7508.715384615465.5216065996.8570.753846154464.9455800617.5632.792307692460.91339429816.6253136.445.546.342.837.13.910.823.835.385.884.684.774.56658.654.744.836.226.620.114.215.415.38.9910.48.95.86.76.87.5FirefoxChromeIEOthers
In [21]:
stackedline_chart = pygal.StackedLine(fill=True)
stackedline_chart.title = 'Browser usage evolution (in %)'
stackedline_chart.x_labels = map(str, range(2002, 2013))
stackedline_chart.add('Firefox', [None, None, 0, 16.6,   25,   31, 36.4, 45.5, 46.3, 42.8, 37.1])
stackedline_chart.add('Chrome',  [None, None, None, None, None, None,    0,  3.9, 10.8, 23.8, 35.3])
stackedline_chart.add('IE',      [85.8, 84.6, 84.7, 74.5,   66, 58.6, 54.7, 44.8, 36.2, 26.6, 20.1])
stackedline_chart.add('Others',  [14.2, 15.4, 15.3,  8.9,    9, 10.4,  8.9,  5.8,  6.7,  6.8,  7.5])
HTML(html_pygal.format(pygal_render=stackedline_chart.render()))
Out[21]:
Browser usage evolution (in %)0.010.020.030.040.050.060.070.080.090.0100.020022003200420052006200720082009201020112012Browser usage evolution (in %)012.2923076923504.115384615073.7538461538504.1153846150135.215384615504.11538461516.6196.676923077422.07307692325258.138461538380.55769230831319.6350.90384615436.4381.061538462324.21538461545.5442.523076923279.24038461546.3503.984615385275.28653846242.8565.446153846292.58461538537.1626.907692308320.755769231012.2923076923504.115384615073.7538461538504.1153846150135.215384615504.11538461516.6196.676923077422.07307692325258.138461538380.55769230831319.6350.90384615436.4381.061538462324.21538461549.4442.523076923259.96538461557.1503.984615385221.90961538566.6565.446153846174.95769230872.4626.907692308146.29230769285.812.292307692380.065384615484.673.753846153885.996153846284.7135.21538461585.501923076991.1196.67692307753.871153846291258.13846153854.365384615489.6319.661.284615384691.1381.06153846253.871153846294.2442.52307692338.5593.3503.98461538542.998076923193.2565.44615384643.492307692392.5626.90769230846.9519230769100.012.29230769239.88461538462100.073.75384615389.88461538462100.0135.2153846159.88461538462100.0196.6769230779.88461538462100258.1384615389.88461538462100.0319.69.88461538462100.0381.0615384629.88461538462100.0442.5230769239.88461538462100.0503.9846153859.88461538462100.0565.4461538469.88461538462100.0626.9076923089.8846153846216.6253136.445.546.342.837.116.6253136.449.457.166.672.485.884.684.791.19189.691.194.293.393.292.5100.0100.0100.0100.0100100.0100.0100.0100.0100.0100.0FirefoxChromeIEOthers