2

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

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
TourEiffel
  • 4,034
  • 2
  • 16
  • 45

1 Answers1

0

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()

enter image description here

Laurent
  • 12,287
  • 7
  • 21
  • 37