Plotting using seaborn#

When visualizeing quantitative measurements from tables, plots are key.

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
data = pd.read_csv('../../data/Results.csv', index_col=0, delimiter=';')
data
Area Mean StdDev Min Max X Y XM YM Major Minor Angle %Area Type
1 18.0 730.389 103.354 592.0 948.0 435.000 4.722 434.962 4.697 5.987 3.828 168.425 100 A
2 126.0 718.333 90.367 556.0 1046.0 388.087 8.683 388.183 8.687 16.559 9.688 175.471 100 A
3 NaN NaN NaN 608.0 964.0 NaN NaN NaN 7.665 7.359 NaN 101.121 100 A
4 68.0 686.985 61.169 571.0 880.0 126.147 8.809 126.192 8.811 15.136 5.720 168.133 100 A
5 NaN NaN 69.438 566.0 792.0 348.500 7.500 NaN 7.508 NaN 3.088 NaN 100 A
... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
387 152.0 801.599 111.328 582.0 1263.0 348.487 497.632 348.451 497.675 17.773 10.889 11.829 100 A
388 17.0 742.706 69.624 620.0 884.0 420.500 496.382 420.513 NaN NaN 3.663 49.457 100 A
389 60.0 758.033 77.309 601.0 947.0 259.000 499.300 258.990 499.289 9.476 8.062 90.000 100 A
390 12.0 714.833 67.294 551.0 785.0 240.167 498.167 240.179 498.148 4.606 3.317 168.690 100 A
391 23.0 695.043 67.356 611.0 846.0 49.891 503.022 49.882 502.979 6.454 4.537 73.243 100 A

391 rows × 14 columns

For plotting, we can use the seaborn library, for example for visualizing a histogram of values given a table column.

sns.histplot(data = data, x = 'Mean', kde = True);
../_images/plotting_seaborn_4_0.png

Scatter plots#

For visualizing relationships between different parameters, it may make sense to visualze a scatter plot along with histograms.

sns.jointplot(data = data, x = 'X', y = 'Mean');
../_images/plotting_seaborn_6_0.png

This visualization can give futher insights into our given dataset, e.g. by visualizing different groups of samples in different colours. In this example we distinguish samples by their type:

sns.jointplot(data = data,
              x ='X', 
              y= 'Mean',
              hue= 'Type');
../_images/plotting_seaborn_8_0.png