I was wondering how one rotates the x-labels, something in the lines of:
theme(axis.text.x = element_text(angle = 90, hjust = 1))
in ggplot?
Thank you.
I was wondering how one rotates the x-labels, something in the lines of:
theme(axis.text.x = element_text(angle = 90, hjust = 1))
in ggplot?
Thank you.
Plotnine is basically a clone of ggplot, you can call (almost) exactly that.
Here's an example :
import pandas as pd
from datetime import datetime, timedelta
from plotnine import ggplot, geom_point, aes, theme, element_text
now = datetime.now()
ago_28days = now - timedelta(days=28)
delta = now - ago_28days
timestamps = [ago_28days + timedelta(days=i) for i in range(delta.days)]
df = pd.DataFrame(data={'timestamp': timestamps, 'value':list(range(28))})
(ggplot(df) +
geom_point(aes('timestamp', 'value')) +
theme(axis_text_x=element_text(rotation=90, hjust=1))
)
© 2022 - 2024 — McMap. All rights reserved.