class_docstr: A Plotter for generating bar plots.
class_docstr_tok: ["A","Plotter","for","generating","bar","plots","."]
docstr: Draw the bar plot.
  
  If `parameter_dict` contains a 'legend' key pointing to a list of labels,
  this will be used as the legend labels in the plot.
  
  Returns:
    object to be rendered by AgentVisualizer.
docstr_tok: ["Draw","the","bar","plot",".","If","`","parameter_dict","`","contains","a","'legend","'","key","pointing","to","a","list","of","labels",",","this","will","be","used","as","the","legend","labels","in","the","plot",".","Returns",":","object","to","be","rendered","by","AgentVisualizer","."]
code: def draw(self):
      """Draw the bar plot.
  
      If `parameter_dict` contains a 'legend' key pointing to a list of labels,
      this will be used as the legend labels in the plot.
  
      Returns:
        object to be rendered by AgentVisualizer.
      """
      self._setup_plot()
      num_colors = len(self.parameters["colors"])
      bar_data = self.parameters["get_bar_data_fn"]()
      num_actions, num_bins = bar_data.shape
      for i in range(num_actions):
          self.plot.bar(
              np.arange(num_bins),
              bar_data[i],
              color=self.parameters["colors"][i % num_colors],
          )
      if "legend" in self.parameters:
          self.plot.legend(self.parameters["legend"])
      self.fig.canvas.draw()
      # Now transfer to surface.
      width, height = self.fig.canvas.get_width_height()
      if self.plot_surface is None:
          self.plot_surface = pygame.Surface((width, height))
      plot_buffer = np.frombuffer(
          self.fig.canvas.buffer_rgba(), np.uint32
      )
      surf_buffer = np.frombuffer(
          self.plot_surface.get_buffer(), dtype=np.int32
      )
      np.copyto(surf_buffer, plot_buffer)
      return pygame.transform.smoothscale(
          self.plot_surface,
          (self.parameters["width"], self.parameters["height"]),
      )
  
file_path: dopamine/dopamine/utils/bar_plotter.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from dopamine.utils import plotter
  import gin
  import matplotlib
  import matplotlib.pyplot
  import numpy
  import pygame
label_desc: Use image node_id 2 for calling the BarPlotter obj's underlying member method code with example usage: obj.draw() and returns: pygame