Prerequisite: Creat and write on an excel file
XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot different charts using realtime data.
Charts are composed of at least one series of one or more data points. Series themselves are comprised of references to cell ranges.
For plotting the charts on an excel sheet, firstly, create chart object of specific chart type( i.e Area, Stacked Area, Percent Stacked Area cjhart etc.). After creating chart objects, insert data in it and lastly, add that chart object in the sheet object.
Code #1 : Plot the simple Area Chart.
For plotting the simple Area chart on an excel sheet, use add_chart() method with type ‘area’ keyword argument of a workbook object.
Code #2 : Plot the Stacked Area Chart.
For plotting the Stacked Area chart on an excel sheet, use add_chart() method with type ‘area’ and subtype ‘stacked’ keyword argument of a workbook object.
Code #3 : Plot the Percent Stacked Area Chart.
For plotting the Percent Stacked Area chart on an excel sheet, use add_chart() method with type ‘area’ and subtype ‘percent_stacked’ keyword argument of a workbook object.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Python | Create and write on excel file using xlsxwriter module
- List Methods in Python | Set 1 (in, not in, len(), min(), max()…)
- Dictionary Methods in Python | Set 1 (cmp(), len(), items()…)
- Looping Techniques in Python
- Functions in Python
- Python | globals() function
- Python | Pandas str.join() to join string/list elements with passed delimiter
- Python | Pandas Series.str.cat() to concatenate string
- Python | Pandas.Categorical()
- Python | Pandas Categorical DataFrame creation