Plotting Charts in Excel using openpyxl module- Set 1:

Python has a openpyxl library that can be used for performing multiple operations on excel files like reading, writing, arithmetic operations, and plotting of graphs for Data Science. Now we will learn about plotting different charts using realtime data.

Charts need to have at least one series of one or more data points. The series are themselves comprise of references to cell ranges.

For plotting of charts on excel, we need to first create chart object of specific chart class. When chart objects are created, we need to insert data into it and then lastly we need to add the chart object in the sheet object.

Code 1: Plotting of Bar Chart

We need to use BarChart class for plotting bar chart on excel sheet. The class can be used from the submodule openpyxl.chart.

Plotting Charts in Excel(openpyxl module) using Python for Data Science

OUTPUT:

Code 2: Plotting of 3D Bar chart

In order to plot 3D bar chart, we use the BarChart3D class from openpyxl.chart submodule.

Plotting Charts in Excel(openpyxl module) using Python for Data Science

OUTPUT:

Plotting Charts in Excel(openpyxl module) using Python for Data Science

Code3: Plotting of Area Chart

In order to plot Area chart on excel sheet, we use AreaChart class from the submodule openpyxl.chart.

Plotting Charts in Excel(openpyxl module) using Python for Data Science

OUTPUT:

Code 4: Plotting 3D Area Chart

In order to plot 3D Area chart on excel sheet, we use AreaChart3D class from the submodule openpyxl.chart.

OUTPUT:

Code 5: Plotting a line chart

In order to plot a line chart on excel sheet, we use LineChart class from the submodule openpyxl.chart.

OUTPUT:

Code6: Plotting a 3D Line chart

In order to plot a 3D line chart on excel sheet, we use LineChart3D class from the submodule openpyxl.chart.

OUTPUT:

Plotting Charts in Excel(openpyxl module) using Python for Data Science

To learn more about graphs in python for data science, you can check this and this as well.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.