Skip to content

Instantly share code, notes, and snippets.

@vnegi10
Last active August 6, 2023 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vnegi10/6c1260baa673443798af923959e4269d to your computer and use it in GitHub Desktop.
Save vnegi10/6c1260baa673443798af923959e4269d to your computer and use it in GitHub Desktop.
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