Python third-party library OPENPYXL (5)Bubble chart
A bubble chart is similar to a scatter plot, but a third dimension is used to determine the size of the bubble, and the chart can include multiple items
fromOpenpyxlImportWorkbook fromOpenpyxl.chartImportSeries, Reference, BUBBLECHARTWB=Workbook () WS=wb.activerows= [ (" Number of products","Sales in USD","Market Share"), (14, 12200, 15), (20, 60000, 33), (18, 24400, 10), (22, 32000, 42), (), (12, 8200, 18), (15, 50000, 30), (19, 22400, 15), (25, 25000, 50),] forRowinchrows:ws.append (ROW) chart=Bubblechart () Chart.style= 18#Use a preset style#Add The first series of dataXValues = Reference (WS, Min_col=1, min_row=2, max_row=5) Yvalues= Reference (WS, min_col=2, min_row=2, max_row=5) Size= Reference (WS, Min_col=3, min_row=2, max_row=5) Series= Series (Values=yvalues, Xvalues=xvalues, Zvalues=size, title=" -") chart.series.append (series)#Add the secondXValues = Reference (WS, Min_col=1, min_row=7, max_row=10) Yvalues= Reference (WS, min_col=2, min_row=7, max_row=10) Size= Reference (WS, Min_col=3, min_row=7, max_row=10) Series= Series (Values=yvalues, Xvalues=xvalues, Zvalues=size, title=" the") chart.series.append (series)#Place the chart starting in cell E1Ws.add_chart (Chart,"E1") Wb.save ("bubble.xlsx")
Run results
Python third-party library OPENPYXL (5)