def __init__(self, observation_space, substation_layout=None, radius_sub=25., load_prod_dist=70., bus_radius=4., alpha_obj=0.3, figsize=(15, 15)): BasePlot.__init__(self, substation_layout=substation_layout, observation_space=observation_space, radius_sub=radius_sub, load_prod_dist=load_prod_dist, bus_radius=bus_radius) if not can_plot: raise RuntimeError("Impossible to plot as matplotlib cannot be imported. Please install \"matplotlib\" " " with \"pip install --update matplotlib\"") self.alpha_obj = alpha_obj self.col_line = "b" self.col_sub = "r" self.col_load = "k" self.col_gen = "g" self.figsize = figsize self.default_color = "k" self.my_cmap = plt.get_cmap("Reds") self.accepted_figure_class = matplotlib.figure.Figure self.accepted_figure_class_tuple = (matplotlib.figure.Figure, matplotlib.axes.Axes)
def __init__(self, observation_space, substation_layout=None, radius_sub=25., load_prod_dist=70., bus_radius=4.): """ Parameters ---------- substation_layout: ``list`` List of tupe given the position of each of the substation of the powergrid. observation_space: :class:`grid2op.Observation.ObservationSpace` BaseObservation space """ BasePlot.__init__(self, substation_layout=substation_layout, observation_space=observation_space, radius_sub=radius_sub, load_prod_dist=load_prod_dist, bus_radius=bus_radius) if not can_plot: raise PlotError( "Impossible to plot as plotly cannot be imported. Please install \"plotly\" and " "\"seaborn\" with \"pip install --update plotly seaborn\"") # define a color palette, whatever... sns.set() pal = sns.light_palette("darkred", 8) self.cols = pal.as_hex()[1:] self.col_line = "royalblue" self.col_sub = "red" self.col_load = "black" self.col_gen = "darkgreen" self.default_color = "black" self.type_fig_allowed = go.Figure
def __init__(self, observation_space, substation_layout=None, radius_sub=20., load_prod_dist=70., bus_radius=5., timestep_duration_seconds=1., fontsize=20): """ Parameters ---------- substation_layout: ``list`` List of tupe given the position of each of the substation of the powergrid. observation_space: :class:`grid2op.Observation.ObservationSpace` BaseObservation space used for the display radius_sub: ``int`` radius (in pixel) of the substations representation. load_prod_dist: ``int`` distance (in pixels) between the substation and the load or the generator. bus_radius: ``int`` The buses are represented by small circles. This is the radius (in pixel) for the pixels representing the buses. timestep_duration_seconds: ``float`` Minimum time during which a time step will stay on the screen, in second. fontsize: ``int`` size of the font used to display the texts. """ if not can_plot: raise PlotError("Impossible to plot as pygame cannot be imported.") self.window_grid = (1000, 700) self.lag_x = 150 self.lag_y = 100 BasePlot.__init__(self, substation_layout=substation_layout, observation_space=observation_space, radius_sub=radius_sub, load_prod_dist=load_prod_dist, bus_radius=bus_radius) # pygame self.__is_init = False self.video_width, self.video_height = 1300, 700 self.timestep_duration_seconds = timestep_duration_seconds self.time_last = None self.fontsize = fontsize self.background_color = [70, 70, 73] # init pygame self.display_called = None self.screen = None self.font = None self.init_pygame() # pause button self.font_pause = pygame.font.Font(None, 30) self.color_text = pygame.Color(255, 255, 255) self.text_paused = self.font_pause.render("Game Paused", True, self.color_text) # maximum overflow possible self.rho_max = 2. # utilities self.cum_reward = 0. self.nb_timestep = 0 # colors self.col_line = pygame.Color(0, 0, 255) self.col_sub = pygame.Color(255, 0, 0) self.col_load = pygame.Color(0, 0, 0) self.col_gen = pygame.Color(0, 255, 0) self.default_color = pygame.Color(0, 0, 0) # deactivate the display on the screen self._deactivate_display = False