我正在尋找使用Pythonmedian_area繪制disturbance_code2020 年以下數(shù)據(jù)框的圖。ggplotscenario | year | disturbance_code | median_area------------------------------------------------Base | 2020 | 1001 | 14264Base | 2020 | 1002 | 6637Base | 2020 | 1003 | 18190Base | 2021 | 1001 | 15000Base | 2021 | 1002 | 3615Base | 2021 | 1003 | 3132我的代碼非常簡(jiǎn)單:import pandas as pdimport numpy as npfrom ggplot import *data # this is the dataframe above - it comes from elsewhere in my actual codeggplot(aes(x = 'disturbance_code', y = 'median_area', fill = 'scenario'), data = data_frame[data_frame['year'] == int(2020)]) +\ theme_bw() +\ geom_bar(stat = 'identity', position = 'dodge') +\ labs(x = 'Severity', y = 'Area burned (ha)')這給出了以下情節(jié):然而,非常奇怪的是,簡(jiǎn)單替換geom_bar()withgeom_line會(huì)得到:
1 回答

皈依舞
TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超3個(gè)贊
簡(jiǎn)而言之,答案是替換y = 'median_area'
為weight = 'median_area'
。
添加回答
舉報(bào)
0/150
提交
取消