我正在寻找使用Pythonmedian_area绘制disturbance_code2020 年以下数据框的图。ggplot
scenario | year | disturbance_code | median_area
------------------------------------------------
Base | 2020 | 1001 | 14264
Base | 2020 | 1002 | 6637
Base | 2020 | 1003 | 18190
Base | 2021 | 1001 | 15000
Base | 2021 | 1002 | 3615
Base | 2021 | 1003 | 3132
我的代码非常简单:
import pandas as pd
import numpy as np
from ggplot import *
data # this is the dataframe above - it comes from elsewhere in my actual code
ggplot(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)')
这给出了以下情节:
然而,非常奇怪的是,简单替换geom_bar()
withgeom_line
会得到:
皈依舞
相关分类