A quick guide for seaborn plot in python© Karobben

A quick guide for seaborn plot in python

Searborn

import seaborn as sns

Countplot

source: seaborn.pydata.org

import seaborn as sns

sns.set_theme(style="darkgrid")
titanic = sns.load_dataset("titanic")
ax = sns.countplot(x="class", data=titanic)

Title

fig, ax = plt.subplots()
ax.set(title='Points vs. Assists')

# or
ax.set_title("Title",fontsize=50)
© Zach; 2021

Axis

Axis text rotation

fig, ax = plt.subplots()
ax.set_xticklabels(ax.get_xticklabels(),rotation = 30)
© delftstack; 2021

Labels

Reference: armatita; 2016

fig, ax = plt.subplots()
ax.set_xlabel("X Label",fontsize=30)
© armatita; 2016

Limits

fig, ax = plt.subplots()
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)

Ledgend

remove

# works on parts of plot
sns.scatterplot(y = s_y, x = s_x, hue = cat, legend = False)


# using function from matplotlib
plt.legend([],[], frameon=False)

A quick guide for seaborn plot in python

https://karobben.github.io/2021/11/06/Python/seaborn/

Author

Karobben

Posted on

2021-11-06

Updated on

2024-01-11

Licensed under

Comments