Skip to content

Commit

Permalink
Adding drop_reg, title and two new possible extension_values to plot_GDP
Browse files Browse the repository at this point in the history
  • Loading branch information
nigolred committed Dec 29, 2021
1 parent efcaa06 commit df7ff7e
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion mario/core/AttrData.py
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,8 @@ def plot_gdp(
extension=None,
extension_value="relative",
auto_open=True,
drop_reg=None,
title=None
):

"""Plots sectoral GDP with additional info
Expand All @@ -1983,10 +1985,16 @@ def plot_gdp(
auto_open : boolean
if True, the plot will be opened automatically
drop_reg : str, optional
a region to be excluded in the plot can be passed. Useful when using MRIO with one region and a Rest of the World region.
title: str, optional
here the user can pass a costume title for the plot
"""

plots = ["treemap", "sunburst"]
extension_values = ["relative", "absolute"]
extension_values = ["relative", "absolute","specific footprint","absolute footprint"]

if plot not in plots:
raise WrongInput(f"Acceptable plots are {plots}")
Expand All @@ -2010,6 +2018,15 @@ def plot_gdp(
if extension_value == "relative":
matrix = "e"
color = "{} [{}]/ Production"

elif extension_value == "specific footprint":
matrix = "f"
color = "{} [{}]/ Production"

elif extension_value == "absolute footprint":
matrix = "F"
color = "{} [{}]"

else:
matrix = "E"
color = "{} [{}]"
Expand Down Expand Up @@ -2043,12 +2060,18 @@ def plot_gdp(
]
values = "GDP"

if drop_reg == None:
data_frame=data_frame
else:
data_frame=data_frame.loc[data_frame.Region!=drop_reg]

fig = getattr(px, plot)(
data_frame=data_frame,
path=_path,
values=values,
color=color,
color_continuous_scale=px.colors.diverging.RdBu[::-1],
title=title
)

path = r"{}".format(self._getdir(path, "Plots", f"GDP_{scenario}_{plot}.html"))
Expand Down

0 comments on commit df7ff7e

Please sign in to comment.