Last active
August 6, 2023 15:35
-
-
Save vnegi10/6c1260baa673443798af923959e4269d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function plot_daily_gas_usage(df_all_gas::DataFrame, | |
month::String, | |
year::Int64) | |
df_gas = process_gas_df(df_all_gas) | |
df_gas = filter(row -> occursin(month, Dates.monthname(row.Date)) && | |
Dates.year(row.Date) == year, | |
df_gas) | |
total_gas = sum(df_gas.CentralHeating) + sum(df_gas.HotWater) | |
total_gas = round(total_gas, digits = 2) | |
sdf_gas = stack(df_gas, | |
[:CentralHeating, :HotWater], | |
variable_name = :UsageType, | |
value_name = :UsageUnits) | |
figure = sdf_gas |> | |
@vlplot(:bar, | |
x = {:Date, | |
"axis" = {"title" = "Time", | |
"labelFontSize" = 10, | |
"titleFontSize" = 12, | |
}}, | |
y = {:UsageUnits, | |
"axis" = {"title" = "Gas usage [m^3]", | |
"labelFontSize" = 10, | |
"titleFontSize" = 12 }}, | |
width = 500, | |
height = 300, | |
"title" = {"text" = "Daily gas usage from $month - $year, total = $total_gas m^3", | |
"fontSize" = 14}, | |
color = :UsageType) | |
return figure | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment