Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Matplotlib rotated xticklabels

import matplotlib.pyplot as plt

x = range(6)
y = [-3, -2, -1, 1, 2, 3]
xlabels = [f'label {i}' for i in x]

fig, ax = plt.subplots()
ax.bar(x, y)

# ha='***' is not enough to visually align labels with ticks 
# use both ha='***' and rotation_mode='anchor'
ax.set_xticks(x, xlabels, rotation=45, ha='right', rotation_mode='anchor')

plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: print in python without using print or sys module 
Python :: create 8ball command in discord.py 
Python :: python array methods 
Python :: group by, aggregate multiple column -pandas 
Python :: django get_user_model() function 
Python :: python venv flask 
Python :: if number is divisible by 3 python 
Python :: Math Module tan() Function in python 
Python :: python create a grid of points 
Python :: file manage py line 17 from exc django 
Python :: BeautifulSoup(raw_html 
Python :: python cli click 
Python :: get last 3 elements in a list python 
Python :: rounding values in pandas dataframe 
Python :: how to give a role permissions discord py 
Python :: python index 2d array 
Python :: Access item in a list of lists 
Python :: php datatables serverside 
Python :: convert to datetime object 
Python :: pandas isin 
Python :: python extract list from string 
Python :: planets with python coding 
Python :: reverse python 
Python :: python strptime() 
Python :: python ufeff 
Python :: input pythhon 
Python :: python if and 
Python :: pandas drop missing values for any column 
Python :: Video to text convertor in python 
Python :: concat string columns in pandas 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =