Mis a jour le 2024-10-20, 20:16

relplot

relplot est la fonction générique qui permet de faire des plots entre 2 variables quantitatives : soit des scatterplots, soit des lineplots :
df = pandas.DataFrame({'X': [1, 2, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5], 'Y': [1, 4, 9, 16, 25, 1, 0, 2, 4, 3, 1, 4, 5, 5, 6], 'Z': ['a', 'a', 'a', 'a', 'a', 'b','b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b']}) seaborn.relplot(x = 'X', y = 'Y', col = 'Z', data = df, kind = 'line', marker = 'o', col_order = ['b', 'a'])
Paramètres :
Avec style : df = pandas.DataFrame({'X': [1, 2, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5], 'Y': [1, 4, 9, 16, 25, 1, 0, 2, 4, 3, 1, 4, 5, 5, 6], 'Z': ['a', 'a', 'a', 'a', 'a', 'b','b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b']}) seaborn.relplot(x = 'X', y = 'Y', style = 'Z', data = df, kind = 'line', markers = {'a': 'D', 'b': 'o'}, dashes = {'a': (3, 0), 'b': (2, 2)}, ci = 'sd', err_style = 'bars')
Avec hue : df = pandas.DataFrame({'X': [1, 2, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5], 'Y': [1, 4, 9, 16, 25, 1, 0, 2, 4, 3, 1, 4, 5, 5, 6], 'Z': ['a', 'a', 'a', 'a', 'a', 'b','b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b']}) seaborn.relplot(x = 'X', y = 'Y', hue = 'Z', data = df, kind = 'line', marker = 'D', markersize = 10, palette = {'a': 'red', 'b': 'blue'}, ci = 'sd', err_style = 'bars')
Avec plusieurs graphes : df = pandas.DataFrame({'X': [1, 2, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5], 'Y': [1, 4, 9, 16, 25, 1, 0, 2, 4, 3, 1, 4, 5, 5, 6], 'Z': ['a', 'a', 'a', 'a', 'a', 'b','b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b']}) seaborn.relplot(x = 'X', y = 'Y', col = 'Z', data = df, kind = 'line', marker = 'D', markersize = 10, ci = 'sd', err_style = 'bars', height = 3, aspect = 2, facet_kws = {'sharey': False, 'xlim': [0, 6]})

Copyright python-simple.com
programmer en python, tutoriel python, graphes en python, Aymeric Duclert