Answers for "how to rotate labels in seaborn"

2

seaborn rotate axis labels

# Basic syntax:
plt.set_xticklabels(plt.get_xticklabels(), rotation=45, horizontalalignment='right')

# Example usage:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Import data
data = pd.read_csv("https://raw.githubusercontent.com/mojones/binders/master/olympics.csv", sep="\t")

# Make figure with rotated axes
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')
Posted by: Guest on May-12-2021
0

seaborn rotate x labels

plt.figure(figsize=(15,8))

ax = sns.histplot(data=test, x='date')

ax.tick_params(axis='x', rotation=90)
Posted by: Guest on August-16-2021
1

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)
Posted by: Guest on May-29-2020
0

seaborn angle lable

chart = data[data['Year'] == 1980]['Sport'].value_counts().plot(kind='bar')
chart.set_xticklabels(chart.get_xticklabels(), rotation=45, horizontalalignment='right')
Posted by: Guest on April-07-2020

Code answers related to "how to rotate labels in seaborn"

Python Answers by Framework

Browse Popular Code Answers by Language