DataScienceAndBigDataAnalytics/Codes/Code-A10 (Data visualisation-3).md

41 lines
857 B
Markdown
Raw Normal View History

# A10 - Data visualization-3
---
1. Import library
```python3
import seaborn as sns
import matplotlib.pyplot as plt
```
2. Load the databset
```python3
dataset = sns.load_dataset("iris")
dataset.head()
```
3. Histogram
```python3
fig, axes = plt.subplots(2, 2, figsize=(16,9))
sns.histplot(dataset['sepal_length'], ax=axes[0,0])
sns.histplot(dataset['sepal_width'], ax=axes[0,1])
sns.histplot(dataset['petal_length'], ax=axes[1,0])
sns.histplot(dataset['petal_width'], ax=axes[1,1])
```
4. Boxplot
```python3
fig, axes = plt.subplots(2, 2, figsize=(16,9))
sns.boxplot(y="petal_length", x="species", data=dataset, ax=axes[0,0])
sns.boxplot(y="petal_width", x="species", data=dataset, ax=axes[0,1])
sns.boxplot(y="sepal_length", x="species", data=dataset, ax=axes[1,0])
sns.boxplot(y="sepal_width", x="species", data=dataset, ax=axes[1,1])
```
---