0

I have some data and want to show them in a scatter matrix thats fine and something I was able to do with:

import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
np.random.seed(100)
xlin = np.linspace(0, 10, 20)
a = xlin*0.2 + np.random.randn(20)*3
b = a*2 + 2 + np.random.randn(20)*3
c = b*0.1 - a*2 + np.random.randn(20)*3
d = a*a*0.1 + np.random.randn(20)*3
df = pd.DataFrame(np.array([a,b,c,d]).T, columns=list('ABCD'))
df.plot()
plt.show()

but now I want to draw a scatter matrix of my dataframe - ok so far, so good I did with:

from pandas.plotting import scatter_matrix
from scipy.stats import linregress
scatter_matrix(df, figsize=(12,12))
plt.show()

Now I want to show the correlations of the datasets using 'linregress'. I even succeeded doing this but only in an extra plot below the scatter matrix. But how do I manage to get as a part of the scatter matrix?

In the end it should look like this: scatter matrix

piterbarg
  • 8,089
  • 2
  • 6
  • 22
riejuhatza
  • 31
  • 2

0 Answers0