Метка с галочкой Seaborn FacetGrid x - PullRequest
0 голосов
/ 05 мая 2020

У меня есть фрейм данных (df), как показано ниже:

df

        Year           Capacity           Qty
0       2010        4,999 and under         2
1       2010        5,000-6,000             1
2       2010        6,100-7,000             3 
3       2011        4,999 and under         5
4       2011        5,000-6,000             3
5       2011        6,100-7,000             3 
....
94      2019        4,999 and under         1
95      2019        5,000-6,000             3
96      201         6,100-7,000             4 

Я хочу создавать подзаголовки в сетке, по одному графику в год. На каждом графике ось x = «Вместимость», ось y = «Qty».

    g = sns.FacetGrid(df, col="Year", col_wrap=3, height=4, aspect=1)
    g.map(sns.barplot, "BTU_Rating", "qty")

Как добавить метку «x», как указано в столбце «Вместимость»?

Спасибо за вашу помощь enter image description here

1 Ответ

1 голос
/ 05 мая 2020
  • Укажите g.set_xticklabels(rotation=x)
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

g = sns.FacetGrid(df, col="Year", col_wrap=3, height=4, aspect=1)

order = ['4,999 and under', '5,000-6,000', '6,100-7,000']
g.map(sns.barplot, "Capacity", "Qty", order=order)

g.set_xticklabels(rotation=90)
plt.show()

enter image description here

...