Home

Seaborn Code Explained

 

So the graph is created with mostly one line of code.

 sns.lmplot(data=df, x="x", y="y",   col="dataset", col_wrap=2, hue="dataset", palette="muted", ci=None, height=4, scatter_kws={"s": 50, "alpha": 1})  


Here the graph is a graph that does a linear lmplot regression from the x and y data that are in the df dataframe.
 sns.lmplot(data=df, x="x", y="y",   col="dataset", col_wrap=2  , hue="dataset", palette="muted", ci=None, height=4, scatter_kws={"s": 50, "alpha": 1}) 


In addition, we can see that not one but 4 graphs have been created at once. There is often the possibility of creating such grids (facetgrids). In fact, this is the case as soon as a function has the row and col parameters. Here the row parameter is not used, in order not to have 4 graphs on the same line we chose to refer to the row from 2 graphs. Of course, the "dataset" field here must be a qualitative variable.
 sns.lmplot(data=df, x="x", y="y", col="dataset", col_wrap=2,   hue="dataset"  , palette="muted", ci=None,    height=4, scatter_kws={"s": 50, "alpha": 1}) 

hue is a color parameter, this means for a qualitative variable that each of its modalities will be displayed in a different color. Other parameters can be used: linestyle: in line charts
size: the size of points in a point cloud or the thickness of a curve.
 sns.lmplot(data=df, x="x", y="y", col="dataset", col_wrap=2, hue="dataset",   palette="muted", ci=None,    height=4, scatter_kws={"s": 50, "alpha": 1}  ) 

The last parameters are color formatting parameters (palette), error bar (ci), grid (height in inches), and parameters (keywords) passed to a lower level function ( scatter_kws).

Settings

Up