【发布时间】:2020-04-10 17:59:55
【问题描述】:
我是使用 Seaborn 的新手,通常只使用 Matplotlib.pyplot。
随着最近 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 notebook 的链接,下面是给我带来问题的部分的 sn-p。
# 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)
###########################
【问题讨论】:
标签: python pandas matplotlib seaborn