python program

WRITE A PROGRAM FOR USING LINEPLOT. INPUT:- 
 import matplotlib.pyplot as plt 
import seaborn as sns sns
set(style="dark") fmri = sns.load_dataset("fmri") 
 sns.lineplot(x="timepoint", 
             y="signal", hue="region", 
 style="event", 
 data=fmri) 
 plt.show()

import matplotlib.pyplot as plt

def plot_bar_graph(x_values, y_values):
    plt.bar(x_values, y_values)
    plt.xlabel('X Values')
    plt.ylabel('Y Values')
    plt.title('Bar Graph of X and Y Values')
    plt.show()
x_values = [1, 2, 3, 4, 5]
y_values = [10, 20, 15, 25, 30]
plot_bar_graph(x_values, y_values)

) WRITE APROGRAM FOR USING DISTPLOT WITH OUT THE HISTOGRAM.

import matplotlib.pyplot as plt import seaborn as sns

sns.distplot([0, 1, 2, 3, 4, 5], hist=False) 

plt.show()


 

Write A Program For Use Of Formating String(--)

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()  


Write A Program for category ploting with categorical variables using subplot. 
from matplotlib import pyplot as plt names = ['Abhishek', 'Himanshu', 'Devansh']  marks= [87,50,98]   



plt.figure(figsize=(9,3))   

   

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().  


Write a program for scatter plotting.  

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()  

 


25 Write a program for scatter plot with the use of legend.   

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