# Plotting a line
()
-----------------
# importing the required module
import [Link] as plt
# x axis values
x = [1, 2, 3]
# corresponding y axis values
y = [2, 4, 1]
# plotting the points
[Link](x, y)
# naming the x axis
[Link]('x - axis')
# naming the y axis
[Link]('y - axis')
# giving a title to my graph
[Link]('My first graph!')
# function to show the plot
[Link]-------------------------------
#Plotting two or more lines on same plot
-----------------------------------
import [Link] as plt
# line 1 points
x1 = [1, 2, 3]
y1 = [2, 4, 1]
# plotting the line 1 points
[Link](x1, y1, label="line 1")
# line 2 points
x2 = [1, 2, 3]
y2 = [4, 1, 3]
# plotting the line 2 points
[Link](x2, y2, label="line 2")
# naming the x axis
[Link]('x - axis')
# naming the y axis
[Link]('y - axis')
# giving a title to my graph
[Link]('Two lines on same graph!')
# show a legend on the plot
[Link]()
# function to show the plot
[Link]()
---------------------------
#Customization of Plots
----------------------
import [Link] as plt
# x axis values
x = [1, 2, 3, 4, 5, 6]
# corresponding y axis values
y = [2, 4, 1, 5, 2, 6]
# plotting the points
[Link](x, y, color='green', linestyle='dashed', linewidth=3,
marker='o', markerfacecolor='blue', markersize=12)
# setting x and y axis range
[Link](1, 8)
[Link](1, 8)
# naming the x axis
[Link]('x - axis')
# naming the y axis
[Link]('y - axis')
# giving a title to my graph
[Link]('Some cool customizations!')
# function to show the plot
[Link]()
---------------------------------------
#Bar Chart
----------------
import [Link] as plt
# x-coordinates of left sides of bars
left = [1, 2, 3, 4, 5]
# heights of bars
height = [10, 24, 36, 40, 5]
# labels for bars
tick_label = ['one', 'two', 'three', 'four', 'five']
# plotting a bar chart
[Link](left, height, tick_label=tick_label,
width=0.8, color=['red', 'green'])
# naming the x-axis
[Link]('x - axis')
# naming the y-axis
[Link]('y - axis')
# plot title
[Link]('My bar chart!')
# function to show the plot
[Link]()
---------------------------------
#Histogram
----------------
import [Link] as plt
# frequencies
ages = [2, 5, 70, 40, 30, 45, 50, 45, 43, 40, 44,
60, 7, 13, 57, 18, 90, 77, 32, 21, 20, 40]
# setting the ranges and no. of intervals
range = (0, 100)
bins = 10
# plotting a histogram
[Link](ages, bins, range, color='green',
histtype='bar', rwidth=0.8)
# x-axis label
[Link]('age')
# frequency label
[Link]('No. of people')
# plot title
[Link]('My histogram')
# function to show the plot
[Link]()
-----------------------------
#Pie-chart
-------------
import [Link] as plt
# defining labels
activities = ['eat', 'sleep', 'work', 'play']
# portion covered by each label
slices = [3, 7, 8, 6]
# color for each label
colors = ['r', 'y', 'g', 'b']
# plotting the pie chart
[Link](slices, labels=activities, colors=colors,
startangle=90, shadow=True, explode=(0, 0, 0.1, 0),
radius=1.2, autopct='%1.1f%%')
# plotting legend
[Link]()
# showing the plot
[Link]()
----------------------------------