In [2]:
from pycharts.charts.pie_chart import PieChart
from pycharts.highcharts_plotter import HighChartsPlotter
data = [
['Firefox', 45.0],
['IE', 26.8],
['Chrome', 12.8],
['Safari', 8.5],
['Opera', 6.2],
['Others', 0.7]
]
data_label = "Browser share"
title = "Browser market shares at a specific website, 2014"
piechart = PieChart(title, data_label, data)
print piechart.to_javascript()
plotter = HighChartsPlotter()
plotter.plot(piechart)
Out[2]:
In [3]:
from pycharts.charts.stacked_bar_chart import StackedBarChart
title = "How do tourists spend their money?"
categories = ['Americans', 'Italians', 'Chinese', 'Brazilians', 'Germans']
data = [
('Bakery', [5, 3, 4, 7, 2]),
('Bars and Restaurants', [2, 2, 4, 3, 8]),
('Shopping', [10, 8, 7, 6, 9]),
('Jewelry', [5, 5, 2, 3, 3]),
('Hotel', [8, 8, 6, 7, 6])
]
y_title = 'Total money spent'
# stackedchart = StackedBarChart(title, categories, data, y_title=y_title, stacking="normal")
stackedchart = StackedBarChart(title, categories, data, y_title=y_title, stacking="percent")
print stackedchart.to_javascript()
plotter = HighChartsPlotter()
plotter.plot(stackedchart)
Out[3]:
In [4]:
from pycharts.charts.bubble_chart import BubbleChart
from pycharts.highcharts_plotter import HighChartsPlotter
title = "How does income, life expectancy and population size relate in each continent?"
x_title = "income"
y_title = "life expectancy"
data = [('Latin America', [[97, 36, 79], [94, 74, 60], [68, 76, 58], [64, 87, 56], [68, 27, 73], [74, 99, 42], [7, 93, 87], [51, 69, 40], [38, 23, 33], [57, 86, 31]]),
('Asia', [[25, 10, 180], [2, 75, 190], [11, 54, 8], [86, 55, 93], [5, 3, 58], [90, 63, 44], [91, 33, 17], [97, 3, 56], [15, 67, 48], [54, 25, 81]]),
('Africa', [[47, 47, 10], [20, 12, 4], [6, 76, 17], [38, 30, 6], [57, 98, 8], [61, 17, 10], [83, 60, 13], [67, 78, 50], [64, 12, 10], [30, 77, 82]])]
bubblechart = BubbleChart(title, data, x_title, y_title)
print bubblechart.to_javascript()
plotter = HighChartsPlotter()
plotter.plot(bubblechart)
Out[4]:
In [5]:
from pycharts.charts.area_chart import AreaChart
from pycharts.highcharts_plotter import HighChartsPlotter
title = "What is the browser market share across time?"
data = [('Firefox', [[2009, 30], [2010, 47], [2011, 35], [2012, 46], [2013, 34], [2014, 40]]),
('IE', [[2009, 50], [2010, 45], [2011, 46], [2012, 40], [2013, 35], [2014, 30]]),
('Chrome', [[2009, 10], [2010, 14], [2011, 20], [2012, 26], [2013, 34], [2014, 40]]),
('Safari', [[2009, 10], [2010, 11], [2011, 12], [2012, 11], [2013, 13], [2014, 15]])]
x_title = "years"
y_title = "share"
# areachart = AreaChart(title, data, stacking=None, x_title=x_title, y_title=y_title)
# areachart = AreaChart(title, data, stacking="normal", x_title=x_title, y_title=y_title)
areachart = AreaChart(title, data, stacking="percent", x_title=x_title, y_title=y_title)
print areachart.to_javascript()
plotter = HighChartsPlotter()
plotter.plot(areachart)
Out[5]:
In [6]:
from pycharts.charts.bubble_map import BubbleMap
from pycharts.highcharts_plotter import HighChartsPlotter
title = "Where do tourists spend money?"
data = [('Americans', [[10, 47.23, 8.04], [14, 47.33, 8.14], [15, 46.48, 9.49]]),
('Italians', [[7, 46.48, 08.49], [9, 46.12, 6.09], [20, 46.10, 8.47]]),
('Chinese', [[20, 47.22, 8.32], [23, 47.0, 8.18], [19, 47.1, 8.31]])]
country_code = 'ch'
bubblemap = BubbleMap(title, data, country_code)
# print bubblemap.to_javascript()
plotter = HighChartsPlotter()
plotter.plot(bubblemap)
Out[6]:
In [ ]:
In [ ]: