- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Rotate tick labels for Seaborn barplot in Matplotib
To rotate tick labels for Seaborn barplot, we can take the following steps −
Make a dataframe using Pandas.
Plot the bar using Seaborn's barplot() method.
Rotate the xticks label by 45 angle.
To display the figure, use the show() method.
Example
import pandas import matplotlib.pylab as plt import seaborn as sns import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pandas.DataFrame({"X-Axis": [np.random.randint(10) for i in range(10)], "YAxis": [i for i in range(10)]}) bar_plot = sns.barplot(x='X-Axis', y='Y-Axis', data=df) plt.xticks(rotation=45) plt.show()
Output
Advertisements