xxxxxxxxxx
# importing the required library
import seaborn as sns
import matplotlib.pyplot as plt
# read a titanic.csv file
# from seaborn library
df = sns.load_dataset('titanic')
# class v / s fare barplot
sns.barplot(x = 'class', y = 'fare', data = df)
# Show the plot
plt.show()
xxxxxxxxxx
import seaborn as sns
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(10,10))
# x and y are lists
sns.barplot(x=x, y=y, color='goldenrod', ax=ax, label="Some Label")
ax.set_xlabel("X-Label")
ax.set_ylabel("Y-Label")
ax.legend()
plt.show()
xxxxxxxxxx
# importing the required library
import seaborn as sns
import matplotlib.pyplot as plt
# read a titanic.csv file
# from seaborn library
df = sns.load_dataset('titanic')
# class v / s fare barplot
sns.barplot(x = 'class', y = 'fare', hue = 'sex', data = df)
# Show the plot
plt.show()
xxxxxxxxxx
import seaborn as sns
import matplotlib.pyplot as plt
# List of categories from lowest to highest
category_order = ["A", "B", "C", "D"]
sns.catplot(x="cat_col", y="col",
data=df, kind="bar",
order=category_order, ci=None) # # Turn off the confidence intervals
# Show plot
plt.show()