add visualise.py, update readme.md

This commit is contained in:
leo 2023-02-25 23:52:51 +01:00
parent a01e63d2a8
commit 102454e6e1
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ
5 changed files with 44 additions and 0 deletions

@ -1,6 +1,7 @@
# p2
this is a Go subproject containing code for task no. 2.
Python is used for visualisation.
### compile
```sh

BIN
p2/res/signal_u.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

BIN
p2/res/signal_y.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

43
p2/visualise.py Normal file

@ -0,0 +1,43 @@
import seaborn as sb
import pandas as pd
import scipy
import matplotlib.pyplot as plt
data_uy=pd.read_csv('data/m.csv')
# head(data_uy)
correlation_result=scipy.stats.pearsonr(data_uy['u'], data_uy['y'])
print(correlation_result)
p = sb.lmplot(
data=data_uy,
x='u',
y='y',
fit_reg=True,
height=8,
)
p.set(title='Correlation UY')
p.savefig('res/uy-correlation-analysis.png')
plt.clf()
lp = sb.lineplot(data=data_uy['u'])
lp.set(
title='Signal u',
xlabel='samples',
ylabel='u',
)
fig = lp.get_figure()
fig.subplots_adjust(top=.97)
fig.savefig('res/signal_u.png')
plt.clf()
lp = sb.lineplot(data=data_uy['y'])
lp.set(
title='Signal y',
xlabel='samples',
ylabel='y',
)
fig = lp.get_figure()
fig.subplots_adjust(top=.97)
fig.savefig('res/signal_y.png')
plt.clf()