DEV Community

Cover image for Intro to Matplotlib in Python, Part1-plot().
Keshav Jindal
Keshav Jindal

Posted on

1 1

Intro to Matplotlib in Python, Part1-plot().

1. What is Matplotlib
It is a library which helps us to plot and visualize the data in 2D form. It is an easy way to represent huge amount of data. It was introduced by John D.Hunter in the year 2002.

2. Why Matplotlib

  • Easy visualization to data.

  • Consist of bar graphs, histograms, pie charts, line graphs, etc.

  • Compatible with other third-party libraries and packages, that extend its functionality.

3. Plotting on X and Y axis

  • By default, the plot() function draws a line from point to point.
  • Also draws points on graph.
  • positions of points are in order. Eg(10,7), here 10 is point on X axis and 7 on Y axis.
  • Example:
import matplotlib.pyplot as plt
import numpy as np

x = np.array([1, 8])
y = np.array([3, 10])
plt.plot(x,y)
plt.show()
Enter fullscreen mode Exit fullscreen mode

OUTPUT

Image description

NOTE

  • The x-axis is the horizontal axis.

  • The y-axis is the vertical axis.

👋 While you are here

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (1)

Collapse
 
giriprasathd profile image
GIRIPRASTH.D •

I'm amazed for you keshav jindal
Learn more python
Pratice, Pratice, Pratice
all the best for your future

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay