import sys import plotly.plotly as py from plotly.graph_objs import * import database_helper result = database_helper.query_number_of_data_points() if result[0] == False: sys.exit(1) res1 = result[1] res2 = result[2] trace1 = Bar( x=['Above -70 dBm', '-70 to -90 dBm', '-90 to -100 dBm', 'Below -100 dBm'], y=res1, name='3G' ) lte = Bar( x=['Above -70 dBm', '-70 to -90 dBm', '-90 to -100 dBm', 'Below -100 dBm'], y=res2, name='LTE' ) data = Data([trace1, lte]) layout = Layout( barmode='stack' ) fig = Figure(data=data, layout=layout) plot_url = py.plot(fig, filename='stacked-bar')