def METHOD_NAME(analysis: Analysis, figure_base_path: Text) -> Text:
  """Create histogram for numerical attributes or bar chart for categorical
  Args:
      analysis: (analysis_pb2.Analysis), the analysis should be one of
      the following
      - HISTOGRAM for histogram of numerical attribute
      - VALUE_COUNTS for bar chart of categorical attributes
      figure_base_path: (string), the folder for holding figures
  Returns:
      string, path of the generated figure
  """
  # pylint: disable-msg=too-many-locals
  supported_analysis = {Analysis.HISTOGRAM, Analysis.VALUE_COUNTS}
  assert analysis.name in supported_analysis
  # The result of supported analysis should be in the format of TableMetric
  table_metric = analysis.tmetrics[0]
  attribute_name = analysis.features[0].name
  columns = []
  if analysis.name == Analysis.HISTOGRAM:
    boundaries = table_metric.column_indexes
    for item in boundaries:
      # For better display, the midpoint of a bin is computed
      boundary = re.findall(r"\d+\.?\d*", item)
      if len(boundary) == 1:
        center = boundary[0] + '+'
      else:
        left, right = boundary
        center = "{0:.2f}".format((float(left) + float(right)) / 2)
      columns.append(center)
  else:
    columns.extend(table_metric.column_indexes)
  # Trim the xlabel to make it look nicer
  columns = _trim_xlabel(columns)
  for row in table_metric.rows:
    row_values = [item.value for item in row.cells]
  df = pd.DataFrame({'bin_name': columns, "Frequency": row_values})
  fig, axs = plt.subplots(figsize=FIGURE_SIZE)
  fig.subplots_adjust(bottom=0.2)
  df.plot.bar(x="bin_name", y="Frequency", ax=axs, width=0.8)
  axs.set_xlabel(attribute_name)
  axs.set_ylabel('Number of records')
  axs.grid(True, which='both')
  output_path = os.path.join(
      figure_base_path, '{}_histogram.png'.format(attribute_name))
  plt.savefig(output_path, dpi=(200))
  return output_path