seaborn rotate axis labels code example
Example 1: seaborn rotate axis labels
plt.set_xticklabels(plt.get_xticklabels(), rotation=45, horizontalalignment='right')
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
data = pd.read_csv("https://raw.githubusercontent.com/mojones/binders/master/olympics.csv", sep="\t")
plt.figure(figsize=(10,5))
chart = sns.countplot(
data=data[data['Year'] == 1980],
x='Sport',
palette='Set1')
chart.set_xticklabels(chart.get_xticklabels(), rotation=45, horizontalalignment='right')
Example 2: seaborn rotate xlabels
plt.figure(figsize=(10,5))
chart = sns.countplot(
data=data[data['Year'] == 1980],
x='Sport',
palette='Set1'
)
chart.set_xticklabels(chart.get_xticklabels(), rotation=45)