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 4

Example : 4 Line Plot

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]

plt.plot(x,y,'g',label='line one', linewidth=5)
plt.plot(x2,y2,'c',label='line two',linewidth=5)

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

plt.legend()

plt.grid(True,color='r')

plt.show()

Python PyPlot  | rajeshshuklacatalyst.com

Example : 5 Line Plot

# importing matplotlib module  
from matplotlib import pyplot as plt 
  
# x-axis values 
x = [5, 2, 9, 4, 7] 
  
# Y-axis values 
y = [10, 5, 8, 4, 2] 
  
# Function to plot 
plt.plot(x,y,'b',label='Line 1',linewidth=5) 

#giving title, x axis, y axis
plt.title('Example Line Plot')
plt.ylabel('Y axis')
plt.xlabel('X axis')

plt.legend()


plt.grid(True,color='r')

# function to show the plot 
plt.show() 

Python PyPlot  | rajeshshuklacatalyst.com

Example : 6 Line Plot

from matplotlib import pyplot as plt
import numpy as np
x = np.arange(1,11)
y = np.random.random(10)
print(x)
print(y)
plt.plot(x,y)
plt.show()

Output:

[ 1 2 3 4 5 6 7 8 9 10]
[0.75769183 0.15878421 0.61943324 0.31750067 0.9580151 0.17189032
0.65672839 0.18876268 0.26326319 0.22721435]
>>>

Python PyPlot  | rajeshshuklacatalyst.com

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

Visitor Counter

0183301