Issue
I have the following line which I use to add labels to my custom cbar but I don't know how to rotate these label
MyCustomBar.set_ticklabels(['< 50 \nand \ndecreasing', '< 50 \nand increasing \nor unchanged', '> 50 \nand decreasing \nor unchanged', '> 50 \nand \nincreasing'])
I tried using ,rotation = 45
but seems not exist for set_ticklabels
Solution
You could try like this:
import pandas as pd
from matplotlib import pyplot as plt
# Toy dataframe
df = pd.util.testing.makeDataFrame()[0:4]
plt.plot(df.index, df["A"], "o--", df.index, df["B"], "x-")
plt.xticks(
df.index,
[
"< 50 \nand \ndecreasing",
"< 50 \nand increasing \nor unchanged",
"> 50 \nand decreasing \nor unchanged",
"> 50 \nand \nincreasing",
],
rotation=45,
)
plt.show()
Answered By - Laurent
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.