我是使用Seaborn的新手,通常只使用马特洛利布。
随着最近的COVID发展,一位主管要求我汇总学生人数的变化以及我们需要为受影响的学生费用提供资金的费用的估计(我在大学预算办公室工作)。我已经能够将我的场景分析放在一起,但现在正试图在热图中可视化这些结果。
我希望能够做的是拥有:
x-axis be my population change rates,
y_axis be my expense change rates,
cmap be my new student fees depending on the x & y axis.
我的代码当前正在执行的操作是:
x-axis is displaying the new student fee category (not sure how to describe this - see picture)
y-axis is displaying the population change and expense change (population, expenses)
cmap is displaying accurately
从本质上讲,我的代码是将每个场景堆叠在y轴上的其他场景之上。
这是当前正在生产的图片,这是不正确的:
示例输出 - 不正确
我用我的代码附加了一个指向Colab Jupyter笔记本的链接,下面是给我带来问题的部分的片段。
# Create Pandas DF of Scenario Analysis
df = pd.DataFrame(list(zip(Pop, Exp, NewStud, NewTotal)),
index = [i for i in range(0,len(NewStud))],
columns=['Population_Change', 'Expense_Change', 'New_Student_Activity_Fee', 'New_Total_Fee'])
# Group this scenario analysis
df = df.groupby(['Population_Change', 'Expense_Change'], sort=False).max()
# Create Figure
fig = plt.figure(figsize=(15,8))
ax = plt.subplot(111)
# Drop New Student Activity Fee Column. Analyze Only New Total Fee
df = df.drop(['New_Student_Activity_Fee'], axis=1)
########################### Not Working As Desired
sb.heatmap(df)
###########################
凤凰求蛊
相关分类