我试图在ggplot2
python3
上翻转我的条形图上的坐标但是没有成功。难道我做错了什么?
import ggplot
print(ggplot.__version__)
0.11.5
from ggplot import *
import numpy as np
import pandas as pd
# seed
np.random.seed(0)
# toy DF
df = pd.DataFrame({
"x": np.random.choice(range(2001, 2008), 250),
"w": np.random.uniform(50, 400, 250)
})
# data and axis
plt = ggplot(df, aes(weight='w', x='x'))
# bars
plt = plt + geom_bar()
# print
print(plt)
# vertical bars --> horizontal bars
plt = plt + coord_flip()
print(plt)