KEMBAR78
Cheat Sheet Plotting With Matplotlib Using Pandas | PDF | Pie Chart | Data Analysis
0% found this document useful (0 votes)
9 views4 pages

Cheat Sheet Plotting With Matplotlib Using Pandas

Uploaded by

vikranthviki083
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Cheat Sheet Plotting With Matplotlib Using Pandas

Uploaded by

vikranthviki083
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

10/13/23, 3:48 PM about:blank

Data Visualization with Python


Cheat Sheet : Plotting with Matplotlib using Pandas
Plot Type Description Pandas Function Example Visual

Shows trends and changes DataFrame.plot.line()


Line Plot DataFrame.plot(kind = ‘line’)
df.plot(x=’year’, y=’sales’, kind=’line’)
over time

Displays data series as filled


DataFrame.plot.area()
Area Plot areas, showing the DataFrame.plot(kind = ‘area’)
df.plot(kind='area')
relationship between them

Displays bars representing the Series.plot.hist() s.plot(kind='hist', bins=10)


Histogram
data count in each interval/bin Series.plot(kind = ‘hist’, bins = n) df[‘age’].plot(kind='hist', bins=10)

Displays data using DataFrame.plot.bar()


Bar Chart DataFrame.plot(kind = ‘bar’)
df.plot(kind='bar')
rectangular bars
10/13/23, 3:48 PM about:blank

Plot Type Description Pandas Function Example Visual

Displays data as a circular Series.plot.pie()


plot divided into slices, Series.plot(kind = ‘pie’) s.plot(kind='pie’,autopct='%1.1f%%')
Pie Chart DataFrame.plot.pie(y, labels) df.plot(x='Category',y='Percentage',kind='pie')
representing proportions or
DataFrame.plot(kind = ‘pie’)
percentages of a whole

Displays the distribution of a


DataFrame.plot.box()
Box Plot dataset along with key DataFrame.plot(kind = ‘box’)
df_can.plot(kind='box')
statistical measures

Uses Cartesian coordinates


DataFrame.plot.scatter()
Scatter Plot to display values for two DataFrame.plot(x, y, kind = ‘scatter’)
df.plot(x='Height', y='Weight', kind='scatter')
variables

Cheat Sheet : Plotting directly with Matplotlib


10/13/23, 3:48 PM about:blank

Plot Type Description Matplotlib Function Example Visual

Shows trends and changes


Line Plot plt.plot() plt.plot(x, y, color='red', linewidth=2)
over time

Display data series as filled plt.fill_between(x, y1, y2, color='blue',


Area Plot plt.fill_between()
alpha=0.5)
areas

Displays bars representing the plt.hist(data, bins=10, color='orange',


Histogram plt.hist()
edgecolor='black')
data count in each interval/bin

Displays data using rectangular plt.bar(x, height, color='green',


Bar Chart plt.bar()
width=0.5)
bars

Displays data as a circular plot


divided into slices, representing plt.pie(sizes, labels=labels,
Pie Chart plt.pie()
colors=colors, explode=explode)
proportions or percentages of
a whole

Displays the distribution of a


Box Plot dataset along with key plt.boxplot() plt.boxplot(data, notch=True)
statistical measures
10/13/23, 3:48 PM about:blank

Plot Type Description Matplotlib Function Example Visual

Uses Cartesian coordinates to plt.scatter(x, y, color='purple',


Scatter Plot plt.scatter()
marker='o', s=50)
display values for two variables

Creating multiple plots on one


Subplotting plt.subplots() fig, axes = plt.subplots(nrows=2, ncols=2)
figure

plt.title('Title')
Customizing plot: adding plt.xlabel('X Label')
Customization Various customization plt.ylabel('Y Label')
labels, title, legend, grid plt.legend()
plt.grid(True)

Author(s)
Dr. Pooja

Changelog
Date Version Changed by Change Description
2023-06-10 0.1 Dr. Pooja Initial version created

You might also like