Posts

Showing posts from August, 2023

Matplotlib bar and pie chart

 import matplotlib.pyplot as plt import numpy as np a = np.array(['Rubab','Ali','Shahbaz','Ayesha']) b = np.array([95,89,75,40]) plt.title("Result") plt.ylabel("marks") plt.xlabel("Name of Students") plt.bar(a,b, width = .5) plt.show() #pie chart c = np.array([78,21,1]) names = ['Nitrogen', 'Oxygen', 'Other gases'] my_explode = [0, 0 ,0.1] clr = ['#FFAA00','#E0D41E','#00AAFF'] plt.pie(c , labels = names, explode = my_explode, shadow = False, colors = clr) plt.legend(title = 'Gases in air') plt.show()

Matplotlib

 import matplotlib.pyplot as plt import numpy as np  x = np.array([1,2,3,4]) y = np.array([1,3,4,2]) tfont = {'family' : 'serif' , 'color' : '#50CB1E', 'size' : 15 } xfont = {'family' : 'fantasy' , 'color' : "#3C871D" , 'size' : 15 } yfont = {'family' : 'fantasy' , 'color' : "#3C871D" , 'size' : 15 } plt.title("My graph", loc = 'left' , fontdict = tfont) plt.xlabel("X-axis", fontdict = xfont) plt.ylabel("Y-axis" , fontdict = yfont) plt.grid(color = '#D3E05B', linewidth = 0.7, linestyle = '--') plt.plot(x, y, marker ="h", ms= 10, mec = "#000000",mfc = "#A91ECB", ls = "dashed", linewidth = '3', color = "#16E0E0") plt.show() #comparison of two graphs a = np.array([2,3,7,8]) b = np.array([8,9,5,4]) plt.scatter(a,b , s = 30) a = np.array([8,7,5,8]) b = np....