Programming language :: Python matplotlib tutorials - BESTAREWA BlOG

Header Ads

Programming language :: Python matplotlib tutorials

<
Python - Matplotlib
Matplotlib is a python library used to create 2D graphs and plots by using python scripts. It has a module named pyplot which makes things easy for plotting by providing feature to control line styles, font properties, formatting axes etc. It supports a very wide variety of graphs and plots namely - histogram, bar charts, power spectra, error charts etc. It is used along with NumPy to provide an environment that is an effective open source alternative for MatLab. It can also be used with graphics toolkits like PyQt and wxPython.
Conventionally, the package is imported into the Python script by adding the following statement −
from matplotlib import pyplot as plt

Matplotlib Example

The following script produces the sine wave plot using matplotlib.

Example

import numpy as np 
import matplotlib.pyplot as plt  
 
# Compute the x and y coordinates for points on a sine curve 
x = np.arange(0, 3 * np.pi, 0.1) 
y = np.sin(x) 
plt.title("sine wave form") 
 
# Plot the points using matplotlib 
plt.plot(x, y) 
plt.show() 
Its output is as follows −
Sine Wave
We will see lots of examples on using Matplotlib library of python in Data science work in the next chapters.

No comments

Theme images by friztin. Powered by Blogger.