<commit_before>.. _first_steps_7:

First steps 7: Displaying and exporting
=======================================

In the :ref:`previous first steps guides <first_steps_6>`, you created,
customized, and combined visualizations.

In this section, you will use various methods to display and export your
visualizations.

.. _first_steps_7_html_file:

Creating a standalone HTML file
-------------------------------

All examples so far have used the |show| function to save your visualization to
an HTML file. This HTML file contains all the necessary information to display
your plot.

To customize the file Bokeh creates for your visualization, import and call the
|output_file| function. ``output_file()`` accepts various file-related
arguments. For example:

* ``filename``: the filename for the HTML file. If you don't supply a file name,
  Bokeh will use the file name of your python file as a filename for the HTML
  file it creates.
* ``title``: the title for you document (to be used in the HTML's ``<title>``
  tag)

Bokeh creates the HTML file when you call the |show| function. This function
also automatically opens a web browser to display the HTML file.

If you want Bokeh to only generate the file but not open it in a web browser,
use the |save| function instead.

You need to import the |save| and |output_file| functions before using,
just like you did for |show|.

.. literalinclude:: examples/first_steps_7_export_html.py
   :language: python
   :emphasize-lines: 1,8,17

.. seealso::
    For more information on embedding Bokeh visualizations online, see
    :ref:`userguide_embed` in the user guide.

.. note::
    By default, Bokeh-generated HTML files include a standard version of BokehJS
    that is automatically downloaded from Bokeh's servers. Use the argument
    ``mode`` with the function ``output_file()`` to change this behavior. For
    more information, see |output_file| and :class:`~bokeh.resources.Resources`
    in the reference guide.<commit_msg>Update wording for output_file() (#12241)<commit_after>.. _first_steps_7:

First steps 7: Displaying and exporting
=======================================

In the :ref:`previous first steps guides <first_steps_6>`, you created,
customized, and combined visualizations.

In this section, you will use various methods to display and export your
visualizations.

.. _first_steps_7_html_file:

Creating a standalone HTML file
-------------------------------

All examples so far have used the |show| function to save your visualization to
an HTML file. This HTML file contains all the necessary information to display
your plot.

To customize the file Bokeh creates for your visualization, import and call the
|output_file| function. ``output_file()`` accepts various file-related
arguments. For example:

* ``filename``: the filename for the HTML file
* ``title``: the title for you document (to be used in the HTML's ``<title>``
  tag)

If you don't use the ``output_file()`` function to define a custom file name,
Bokeh defaults to using the file name of your Python file as a filename for the
HTML file it creates.

Bokeh creates the HTML file when you call the |show| function. This function
also automatically opens a web browser to display the HTML file.

If you want Bokeh to only generate the file but not open it in a web browser,
use the |save| function instead.

You need to import the |save| and |output_file| functions before using,
just like you did for |show|.

.. literalinclude:: examples/first_steps_7_export_html.py
   :language: python
   :emphasize-lines: 1,8,17

.. seealso::
    For more information on embedding Bokeh visualizations online, see
    :ref:`userguide_embed` in the user guide.

.. note::
    By default, Bokeh-generated HTML files include a standard version of BokehJS
    that is automatically downloaded from Bokeh's servers. Use the argument
    ``mode`` with the function ``output_file()`` to change this behavior. For
    more information, see |output_file| and :class:`~bokeh.resources.Resources`
    in the reference guide.
{'fraction_non_alphanumeric': 0.10266535044422508, 'fraction_numerical': 0.005676209279368213, 'mean_word_length': 4.143401015228426, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6533680', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1069, 'n_words': 540}