我是使用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 Feedf = df.drop(['New_Student_Activity_Fee'], axis=1)########################### Not Working As Desiredsb.heatmap(df)###########################
Seaborn 熱圖未將數據正確放置在軸上
慕桂英4014372
2022-09-27 14:55:28
