Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (16.4k points)

Hello all, I'm just trying to plot a pair plot with the help of this correlation data:

ozone,radiation,temperature,wind,

1.0,0.3483416929936026,0.6985414096486389,-0.6129507522144628

0.3483416929936026,1.0,0.2940876437245132,-0.12736562398818144

0.6985414096486389,0.2940876437245132,1.0,-0.49714591092004284

-0.6129507522144628,-0.12736562398818144,-0.49714591092004284,1.0

I got poor results, when I attempted with pandas, If necessary, I would also prefer to plot it. I'm trying my best to find the solutions in online for this specific question, but I can't find them. Can anyone please help me?

1 Answer

0 votes
by (26.4k points)

You can try:

import pandas as pd

import numpy as np

import seaborn as sns

import matplotlib.pyplot as plt

df = pd.DataFrame({'ozone': [1.0, 0.3483416929936026, 0.6985414096486389, -0.6129507522144628],

               'radiation': [0.3483416929936026, 1.0, 0.2940876437245132, -0.12736562398818144],

               'temperature':[0.6985414096486389, 0.2940876437245132, 1.0, -0.49714591092004284],

               'wind': [-0.6129507522144628, -0.12736562398818144, -0.49714591092004284, 1.0]})

g = pd.plotting.scatter_matrix(df, figsize=(10,10), marker = 'o', hist_kwds = {'bins': 10}, s = 60, alpha = 0.8)

plt.show()

You can also do this using seaborn

# Plot using Seaborn

sns.pairplot(df, diag_kws={'bins': 10})

Join the python course to learn topics related to python.

Related questions

0 votes
1 answer
asked Oct 9, 2019 in Python by Sammy (47.6k points)
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...