=====================
Visualize with Python
=====================

Visualizations allow you to transform entire data sheets or specific cell selections into charts to help you understand your data. Anaconda provides a variety of charts so you can present your data in a way that makes sense for your use case. 

Creating a chart
================

Create a new chart using the following steps:

#. Under **Visualizations**, click **Visualize with Python**.
#. Click **+ New Chart**.
#. Select a chart type from the list of charts.
#. Select your source data range and configure the controls on the **Setup** tab. 

    .. thumbnail:: /img/toolbox/visualize_setup.png
       :align: center

#. (Optional) Customize your chart further with the options provided on the **Design** tab.

    .. thumbnail:: /img/toolbox/visualize_design.png
       :align: center

#. Click **Create**. 
#. Set the location for the chart to render, then click **OK**. The chart renders within the confines of the cell.

    .. tip::
        To move a chart to a new cell after creating it, click |action| actions beside the chart, then select **Move**.

            .. thumbnail:: /img/toolbox/visualize_chart_move.png
               :align: center

#. To properly view the chart, select the cell, then click **Create Reference**.

    .. thumbnail:: /img/toolbox/visualize_render.png
       :align: center

    The chart displays as an enlarged copy. If you'd prefer to view the enlarged chart only when needed, you can delete the enlarged copy and recreate it at any time.

    .. thumbnail:: /img/toolbox/visualize_chart.png
       :align: center

Editing a chart
===============

Edit an existing chart by adjusting the parameters provided on the **Setup** and **Design** tabs or by manually configuring the code on the **Code** tab.

.. tab-set::

    .. tab-item:: Setup and Design

        #. From the Visualizations home page, click the chart you want to edit.

            .. thumbnail:: /img/toolbox/visualize_edit.png
                :align: center

        #. Make any necessary changes on the **Setup** and **Design** tabs, then click **Apply**.

    .. tab-item:: Code

        The **Code** tab displays auto-generated code based on your selections in the **Setup** and **Design** tabs. While the tabs offer numerous configuration options, the underlying Python library (seaborn) offers additional flexibility, as detailed in their `API documentation <https://seaborn.pydata.org/api.html#function-interface>`_. 
        
        To take advantage of this flexibility: 
        
        #. Enter |edit| **Edit** mode on the **Code** tab. 
      
            .. thumbnail:: /img/toolbox/visualize_code.png
                :align: center        
        
        #. Make any necessary changes to the code, then click **Apply**.

        While you are in |edit| **Edit** mode, the **Setup** and **Design** tabs become locked because free-form code changes cannot be reflected back to the UI elements in the **Setup** and **Design** tabs.

        .. caution:: 
            Once you edit a chart's code manually, you cannot return to using the **Setup** and **Design** tabs to configure your chart without first discarding all of the changes you've made to the chart's code. The reason is that the **Setup** and **Design** tabs will again auto-generate code and overwrite any existing code in the **Code** tab.

.. |action| raw:: html

        <svg width="1em" height="1em" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
    <path d="M7.5 4C8.325 4 9 3.325 9 2.5C9 1.675 8.325 1 7.5 1C6.675 1 6 1.675 6 2.5C6 3.325 6.675 4 7.5 4Z"/>
    <path d="M7.5 6C6.675 6 6 6.675 6 7.5C6 8.325 6.675 9 7.5 9C8.325 9 9 8.325 9 7.5C9 6.675 8.325 6 7.5 6Z"/>
    <path d="M7.5 11C6.675 11 6 11.675 6 12.5C6 13.325 6.675 14 7.5 14C8.325 14 9 13.325 9 12.5C9 11.675 8.325 11 7.5 11Z"/>
    </svg>

.. |edit| raw:: html

        <svg class="inline" width="1em" height="1em" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
    <path fill-rule="evenodd" clip-rule="evenodd" d="M10.4656 2.70625L11.8812 1.29062C12.2687 0.903125 12.9062 0.903125 13.2968 1.29062L14.7125 2.70625C15.1 3.09375 15.1 3.73125 14.7125 4.12188L13.2968 5.5375L10.4656 2.70625ZM9.75937 3.4125L1 12.1719V15H3.82812L12.5875 6.24062L9.75937 3.4125ZM2.41565 12.1719L3.1219 12.8781L10.4656 5.53438L9.7594 4.82812L2.41565 12.1719Z" />
    </svg>
