Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

pandas
python3
area plot

Area plot in pandas

Educative Answers Team

pandas is a popular Python-based data analysis toolkit that can be imported using:

" import pandas as pd "

It presents a diverse range of utilities from parsing multiple file-formats to converting an entire data table into a NumPy matrix array. This property makes pandas a trusted ally in data science and machine learning.

pandas can help with the creation of multiple types of data analysis graphs. One such graph is the density plota plot visually showing the contribution of each variable.

The default implementation of area plot is:

DataFrame.plot.area( x=None, y = None, stacked = True, **kwargs)

Parameters

  • x: label or position - x-coordinates. It uses index by default.

  • y: label or position - Column to plot. It uses all columns by default.

  • stacked: bool - The area plots are stacked.

  • **kwargs: tuple (rows, columns) - All other plotting keyword arguments to be passed to DataFrame.plot().

Code

The following code shows how an area plot can be added in Python. You can change different parameters and look at how the output varies.

main.py
dataset.csv
#import library
import pandas as pd

#add csv file to dataframe
df = pd.read_csv('dataset.csv')

#create area plot
areaplot = df.plot.area( figsize = (5,5), stacked= False)

RELATED TAGS

pandas
python3
area plot
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring