Plotting#

Bauwerk provides custom plotting functionality via the bauwerk.utils.plotting.EnvPlotter class. This enables the plotting of agent trajectories. An example of using this functionality is given below:

[1]:
import bauwerk
import bauwerk.utils.plotting
import gym
import matplotlib.pyplot as plt

env = gym.make("bauwerk/House-v0")
initial_obs = env.reset() # assumes OpenAI Gym v0.21
plotter = bauwerk.utils.plotting.EnvPlotter(
    initial_obs, env, visible_h=24
)
for _ in range(24):
    action = env.action_space.sample()
    step_return = env.step(action)
    plotter.add_step_data(action=action, step_return=step_return)

plotter.update_figure()
plt.show()
<__array_function__ internals>:200: RuntimeWarning: overflow encountered in cast
../../_images/early-access_advanced_plotting_1_1.png

Detailed plotting API#

class bauwerk.utils.plotting.EnvPlotter(initial_obs, env, visible_h=24, fig_height=600, debug_mode=False, include_house_figure=False, alternative_plotting=True, include_clock_in_house_figure=True, score_currency='€', background='white', plot_grid_threshold=True, plot_actions=True, rescale_action=True, plot_optimal_acts=True, interactive_mode=False)[source]#

Plotting class for Bauwerk environments.

Additional information about the plot:

  • The blue dashed line in the top plot

    represents the power threshold above which energy costs more than below.

  • The net load in the top plot is the load

    that has be covered using energy from the grid. It’s the negative residential load plus battery (dis)charge plus PV generation.

  • In the third plot from the top, a red line is

    shown if the action taken by the agent is not feasible, and has to be corrected inside the environment.

  • In the bottom plot, the dotted line is only

    shown if a penalty is actually applied (this may not be case either because the actions are all feasible or because the penalty is not activated).

Parameters
  • initial_obs (dict) – initial observations

  • env (bauwerk.HouseEnv) – environment to plot trajectories from.

  • visible_h (int, optional) – hours of trajectory visible in plot. Defaults to 24.

  • fig_height (int, optional) – height of figure in px. Defaults to 600.

  • debug_mode (bool, optional) – whether to run in debug mode. Defaults to False.

  • include_house_figure (bool, optional) – whether to include figure of house. Mostly useful in the context of interactive plotting as part of Bauwerk game. Defaults to False.

  • alternative_plotting (bool, optional) – Two variations of plotting are available. The second (alternative) variation is recommended and the default. Defaults to True.

  • include_clock_in_house_figure (bool, optional) – whether to include a clock in the house figure (if this one is active). Defaults to True.

  • score_currency (str, optional) – currency shown in score. Defaults to “€”.

  • background (Optional[str], optional) – background color. Defaults to “white”.

  • plot_grid_threshold (bool, optional) – whether to plot peak demand pricing threshold of grid. Defaults to True.

  • plot_actions (bool, optional) – whether to plot actions. Defaults to True.

  • rescale_action (bool, optional) – whether to rescale actions. Defaults to True.

  • plot_optimal_acts (bool, optional) – whether to include a plot of the optimal actions. Defaults to True.

  • interactive_mode (bool, optional) – whether Figures should be redrawn for interactive usage, like in Bauwerk game. Defaults to False.

add_step_data(step_return, action)[source]#

Add data from stepping in the environment.

Parameters
  • step_return (tuple) – value returned by stepping in environment (i.e. by env.step(action)).

  • action (np.array) – action that was given to env.step().

Return type

None

reset(obs)[source]#

Reset figure with observation returned by env.reset().

Parameters

obs (dict) – initial observations returned by env.reset().

Return type

None

update_figure()[source]#

Update the figure to current data.