DataVisualization - Jupyter Notebook
DataVisualization - Jupyter Notebook
2 print()
In [35]: 1 x=np.random.randint(1,100,50)
2 r=list(range(1,51))
3 #print(r)
4 plt.subplot(221)
5 plt.plot(x)
6 plt.title("Line Plot")
7
8 plt.subplot(222)
9 plt.scatter(r,x)
10 plt.title("Scatter Plot")
11
12
13 plt.subplot(223)
14 plt.hist(x, bins=[0,20,40,50],edgecolor='r',color='b')
15 plt.title("Scatter Plot")
16
17
18 plt.subplot(224)
19 plt.boxplot(x, vert=False, showmeans=True)
20 plt.title("Scatter Plot")
21
22
23
24 plt.tight_layout()
25 plt.show()
In [20]: 1 import matplotlib.pyplot as plt
2 x=np.random.randint(1,100,50)
3 r=list(range(1,51))
4 #print(r)
5
6 fig, ax=plt.subplots(2,2)
7
8 ax[0,0].plot(x)
9 ax[0,0].set_title("Line Plot")
10
11 ax[0,1].scatter(r,x)
12 ax[0,1].set_title("Line Plot")
13
14
15 ax[1,0].hist(x, bins=[0,20,40,50],edgecolor='r',color='b')
16 ax[1,0].set_title("Line Plot")
17
18
19 ax[1,1].boxplot(x, vert=False, showmeans=True)
20 ax[1,1].set_title("Line Plot")
21
22 fig.tight_layout()
23 plt.show()
In [45]: 1 x[23]=230
2 x[40]=170
3 print(st.median(x))
4 plt.boxplot(x,vert=False, showmeans=True)
5 plt.show()
49.5
In [60]: 1 sub=["Phy","Maths","Etx","CS","Stats"]
2 marks=[54,65,45,76,56]
3 plt.pie(marks,explode=[0.0,0.0,0.0,0.2,0.0],autopct='%2.1f%%', labels=s
4 plt.show()
In [29]: 1 #Donut Chart
2 import matplotlib.pyplot as plt
3 sub=["Phy","Maths","Etx","CS","Stats"]
4 marks=[54,65,45,76,56]
5 fig, ax = plt.subplots()
6 ax.pie(marks, labels=sub, colors=['r','g','b','c','grey'], autopct='%1
7 cc = plt.Circle((0,0),0.80,fc='white')
8 fig.gca().add_artist(cc)
9 ax.set_title("Marks Distribution")
10 plt.show()
C:\Users\Welcome\AppData\Local\Programs\Python\Python39\lib\site-packages
\matplotlib\collections.py:982: RuntimeWarning: invalid value encountered
in sqrt
scale = np.sqrt(self._sizes) * dpi / 72.0 * self._factor
In [89]: 1 import seaborn as sn
2 import numpy as np
3 arr=np.array([[54,65,43,32],[54,43,32,55],[54,65,45,54],[56,54,67,10],[
4 subs=["C","C++","Java","PHP"]
5 names=["Ramesh","Rahul","Ritesh","Rakesh","Mahesh"]
6 sns.heatmap(arr, xticklabels=subs, yticklabels=names, annot=True, cmap=
Out[89]: <AxesSubplot:>
In [110]: 1 plt.figure(figsize=(16,9))
2 plt.subplot(221)
3 sns.boxplot(x="Species",y="SepalLengthCm", data=df)
4
5 plt.subplot(222)
6 sns.boxplot(x="Species",y="SepalWidthCm", data=df)
7 plt.tight_layout()
8 plt.show()
In [111]: 1 import seaborn as sns
2 import matplotlib.pyplot as plt
3
4 # Load the Iris dataset
5 iris = sns.load_dataset('iris')
6
7 # Create a pairplot of the Iris dataset
8 sns.pairplot(iris, hue='species', palette='Set1', diag_kind='hist')
9
10 # Add title
11 plt.suptitle('Pairplot of Iris Dataset', y=1.02)
12
13 # Show the plot
14 plt.show()
15