Python第三方庫之openpyxl(3)

來源:互聯網
上載者:User

標籤:tle   ext   nta   xls   stack   test   線圖   inf   繪圖   

Python第三方庫之openpyxl(3)地區圖

地區圖類似於折線圖,繪圖線下面的地區會被填充,通過將分組設定為“standard”、“stacked”或“percentStacked”,可以獲得不同的變體;“standard”是預設的。

2D地區圖

 

from openpyxl import Workbookfrom openpyxl.chart import (    AreaChart,    Reference,    Series,)wb = Workbook()ws = wb.activerows = [    [‘Number‘, ‘Batch 1‘, ‘Batch 2‘],    [2, 40, 30],    [3, 40, 25],    [4, 50, 30],    [5, 30, 10],    [6, 25, 5],    [7, 50, 10],]for row in rows:    ws.append(row)chart = AreaChart()chart.title = "Area Chart"chart.style = 13chart.x_axis.title = ‘Test‘chart.y_axis.title = ‘Percentage‘cats = Reference(ws, min_col=1, min_row=1, max_row=7)data = Reference(ws, min_col=2, min_row=1, max_col=3, max_row=7)chart.add_data(data, titles_from_data=True)chart.set_categories(cats)ws.add_chart(chart, "A10")wb.save("area.xlsx")
運行結果:

 

  3D地區圖
from openpyxl import Workbookfrom openpyxl.chart import (    AreaChart3D,    Reference,    Series,)wb = Workbook()ws = wb.activerows = [    [‘Number‘, ‘Batch 1‘, ‘Batch 2‘],    [2, 30, 40],    [3, 25, 40],    [4 ,30, 50],    [5 ,10, 30],    [6,  5, 25],    [7 ,10, 50],]for row in rows:    ws.append(row)chart = AreaChart3D()chart.title = "Area Chart"chart.style = 13chart.x_axis.title = ‘Test‘chart.y_axis.title = ‘Percentage‘chart.legend = Nonecats = Reference(ws, min_col=1, min_row=1, max_row=7)data = Reference(ws, min_col=2, min_row=1, max_col=3, max_row=7)chart.add_data(data, titles_from_data=True)chart.set_categories(cats)ws.add_chart(chart, "A10")wb.save("area3D.xlsx")
運行結果

 

 

Python第三方庫之openpyxl(3)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.