Pandas – Plotting

To plot in Pandas, we need to use the plot() method and the Matplotlib library. The pyplot module from Matplotlib is also used for plotting in Pandas. The pyplot.show() is used to display the figure.

Let us see an example:

Output

Pandas Plotting

Let us now see how to plot:

  • Histogram
  • Pie Chart
  • Scatter Plot
  • Area Plot

Histogram

A histogram is a graphical representation to show frequency distributions.

We will create a Histogram here. Set the kind argument of the plot() method to hist. For this, we only need a single column. Let us see an example:

Output

Pandas Histogram

Pie Chart

Pie Chart displays data in a pictorial form, divided into slices.

We will create a Pie Chart here. Use the plot.pie() method to draw a Pie Chart. Let us see an example:

Output

Pandas Pie Chart

Scatter Plot

A Scatter Plot is a chart that displays the relationship between two variables. A dot represents each value in the data set.

We will create a Scatter Plot here. Set the kind argument of the plot() method to scatter. For this, we will also set the x-axis and y-axis. Let us see an example:

Output

Pandas Scatter Plot

 

Area Plot

The area plot displays quantitative data visually. The area between the axis and the line is commonly filled with colors or textures.

We will create an Area Plot here. Use the plot.area() method to draw an Area Plot. Let us see an example. Let us see an example:

Output

Pandas Area Plot

If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.


For Videos, Join Our YouTube Channel: Join Now


Read More:

Working with Categories in Pandas
Pandas Introduction
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading