Python PyPlot

Python Tutorial @ Home
Introduction
Matplotlib and numpy
Installing NumPy and Matplotlib
Types of visualization
Baisc Visualization rules
Line plot / chart

# Data visualization using pyplot 3

## Line plot/chart

Line plot/chart is a type of plot which displays information as a series of data points called “markers” connected by straight lines. in this type of plot, we need the measurement points to be ordered. this type of plot is often used to visualize a trend in data over intervals of time.

To make a line plot with matplotlib, we call plt.plpt(). the first argument is used for the data on the horizontal axis and the second is used for the data on the vertical axis. this function generates your plot but it doesn’t display it. To display the plot, we need to call the plt.show() function.

In order to draw a line plot, the steps to be followed as under:

1. importing matplotlib

2. pltplot(x,y,color,others) plot y versus x as lines and /or markers

3. plt.xlabel(“text”) set the x-axis label of the current axes.

4. plt.ylabel(text) set the y-axes label of the current axes.

5. plt.set_title(“title”) set a title of the current axes

6. plt.show() display a figure.

### Example:1

```#Importing pyplot
from matplotlib import pyplot as plt

#Plotting to our canvas
plt.plot([1,2,3],[4,5,1])

#Showing what we plotted
plt.show()
``` ### Example:2

```from matplotlib import pyplot as plt

x = [5,8,10]
y = [12,16,6]

plt.plot(x,y)

plt.title('Example Line Plot')
plt.ylabel('Y axis')
plt.xlabel('X axis')

plt.show()
``` ### Example:3

```from matplotlib import pyplot as plt
from matplotlib import style

style.use('ggplot')

x = [5,8,10]
y = [12,16,6]

x2 = [6,9,11]
y2 = [6,15,7]

# can plot specifically, after just showing the defaults:
plt.plot(x,y,linewidth=5)
plt.plot(x2,y2,linewidth=5)

plt.title('Example Line Plot')
plt.ylabel('Y axis')
plt.xlabel('X axis')

plt.show()
``` #### Python Basic Programming Tutorial

Python Introduction     Getting started in Python Programming      Python propgramming fundamentals     Python Operators    Python If Condition     Python for loop    Python range construct      Python While loop    break and continue statements     Different looping techniques     Python List     Python String     Python Functions    Python Inbuilt Functions     Python Recursion     Using Python Library     Python Tuples     Python Dictionary     Python Sets     Python Strings     Python Exception Handling     Python Data File Handling