docs: def write_vega(vega_data, *, title: Optional[str], write_to: str, write_format: str = "auto", indent: int = 2):
      """Write vega dictionary to an external file.
  
      Parameters
      ----------
      vega_data : Valid vega data as dictionary
      write_to: Path to write vega JSON/HTML to.
      write_format: "auto" | "json" | "html"
          Whether to create a JSON data file or a full-fledged HTML page.
      indent: Indentation of JSON
      """
      spec = json.dumps(vega_data, indent=indent)
      if write_format == "html" or write_format is "auto" and write_to.endswith(".html"):
          output = HTML_TEMPLATE.replace("{{ title }}", title or "Histogram").replace("{{ spec }}", spec)
      elif write_format == "json" or write_format is "auto" and write_to.endswith(".json"):
          output = spec
      else:
          raise RuntimeError("Format not understood.")
      with codecs.open(write_to, "w", encoding="utf-8") as out:
          out.write(output)