import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
import seaborn as sns
sns.distplot([0, 1, 2, 3, 4, 5], hist=False)
plt.show()
from matplotlib import pyplot as
plt
plt.plot([1, 2, 3, 4,5], [1, 4, 9,
16,25], '--') plt.axis([0, 6, 0,
20]) plt.show()
plt.subplot(131) plt.bar(names,
marks)
plt.subplot(132)
plt.scatter(names, marks)
plt.subplot(133) plt.plot(names,
marks) plt.suptitle('Categorical
Plotting') plt.show()
Write A Program For Plotting two x and two y value using style and gride.
from matplotlib import pyplot as
plt
from matplotlib import style
style.use('ggplot') x = [16, 8, 10] y = [8, 16, 6] x2 = [8,
15, 11] y2 = [6,
15, 7] plt.plot(x, y, 'r', label='line one', linewidth=5) plt.plot(x2, y2, 'm', label='line two', linewidth=5) plt.title('Epic Info') plt.ylabel('Y axis') plt.xlabel('X axis') plt.legend()
plt.grid(True, color='k')
plt.show()
Write A Program For plotting line graph using numpy.
import numpy as np import
matplotlib.pyplot as plt fig =
plt.figure() ax = plt.axes() x = np.linspace(0, 10, 1000) ax.plot(x, np.sin(x))
Write a Program For make horizontal
bar graph.
from matplotlib import pyplot as plt
players =
['Virat','Rohit','Shikhar','Hardik']
runs = [51,87,45,67] plt.bar(players,runs,color = 'green')
plt.title('Score Card')
plt.xlabel('Players') plt.ylabel('Runs')
plt.show()
Write a Program For make horizontal bar graph.
from matplotlib import pyplot as
plt
players =
['Virat','Rohit','Shikhar','Hardik']
runs = [51,87,45,67] plt.bar(players,runs,color = 'green')
plt.title('Score Card')
plt.xlabel('Players') plt.ylabel('Runs') plt.show()
Write a program for pie chart.
from matplotlib import pyplot as
plt
# Pie chart,
where the slices will be ordered and plotted counterclockwise:
Players = 'Rohit', 'Virat',
'Shikhar', 'Yuvraj' Runs = [45, 30, 15,
10] explode = (0.1, 0, 0, 0) # it "explode" the
1st slice fig1,
ax1 = plt.subplots()
ax1.pie(Runs, explode=explode, labels=Players,
autopct='%1.1f%%',
shadow=True, startangle=90)
ax1.axis('equal')
# Equal aspect ratio ensures that pie is drawn
as a circl e Plt.show().
from matplotlib import pyplot as plt from matplotlib import style
style.use('ggplot') x =
[5,7,10] y = [18,10,6] x2 = [6,9,11] y2
= [7,14,17] plt.scatter(x, y)
plt.scatter(x2, y2, color='g') plt.title('Epic Info') plt.ylabel('Y axis') plt.xlabel('X axis')
plt.show()
import matplotlib.pyplot as
plt x = [2, 2.5, 3, 3.5, 4.5, 4.7,
5.0] y = [7.5, 8, 8.5, 9, 9.5, 10,
10.5] x1 = [9, 8.5, 9, 9.5, 10, 10.5, 12] y1 = [3, 3.5, 4.7, 4, 4.5, 5, 5.2]
plt.scatter(x, y, label='high income low saving',
color='g')
plt.scatter(x1, y1, label='low income high savings',
color='r') plt.xlabel('saving*100') plt.ylabel('income*1000') plt.title('Scatter Plot') plt.grid()
plt.legend() plt.show()
Write a program for import mplot 3d tulkits, numpy and matplotlib in 3d graph with line graph.
# importing mplot3d toolkits, numpy and matplotlib from mpl_toolkits import mplot3d
import numpy as np import
matplotlib.pyplot as plt fig =
plt.figure()
# syntax for 3-D projection ax
= plt.axes(projection ='3d')
Comments