0% found this document useful (0 votes)
47 views8 pages

DataVisualization - Jupyter Notebook

fsd

Uploaded by

Jeevan Tonde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views8 pages

DataVisualization - Jupyter Notebook

fsd

Uploaded by

Jeevan Tonde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

In [*]: 1 %%javascript

2 print()

In [2]: 1 import numpy as np


2 import matplotlib.pyplot as plt
3 import statistics as st

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

In [93]: 1 #Multiple BoxPlot


2 import pandas as pd
3 import matplotlib.pyplot as plt
4 df=pd.DataFrame({"Name":["Sachin","Rahul","Ramesh","Umesh"], "Java":[56
5 df.boxplot()
6 plt.title("TYBSC CS -Marks")
7 plt.show()
8 ​
In [58]: 1 #Multiple boxplot with Subplots
2 import seaborn as sns
3 import pandas as pd
4 df=pd.read_csv("Iris.csv")
5 mp={"Iris-setosa":"g","Iris-versicolor":"b","Iris-virginica":"c"}
6 sns.boxplot(x=df["Species"], y=df["SepalLengthCm"], palette=mp)
7 plt.show()

In [72]: 1 import matplotlib.pyplot as plt


2 import numpy as np
3 x=np.random.randint(0,100,50)
4 y=np.random.randint(0,100,50)
5 sizes=x=np.random.randn(50)*100
6 plt.scatter(x,y, sizes)
7 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 [94]: 1 from wordcloud import WordCloud


2 wc=WordCloud()
3 txt="""India head coach Gautam Gambhir has dispelled any worries about
4 Gambhir also indicated that Sarfaraz Khan could be on the bench in the
5 x=wc.generate(txt)
6 plt.imshow(x)
7 ​

Out[94]: <matplotlib.image.AxesImage at 0x2b5f46385b0>


In [103]: 1 #Write a Python program to create a graph to find relationship between
2 import seaborn as sns
3 import matplotlib.pyplot as plt
4 df=pd.read_csv("Iris.csv")
5 df.columns
6 sns.scatterplot(x='SepalLengthCm', y='SepalWidthCm', data=df, hue='Spec
7 plt.show()

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 ​

You might also like