.. _plot-tutorial:

####################################
Plot2d: Create a Simple Overlay Plot
####################################

.. image:: ../images/tut_plot.png
    :height: 300
    :align: center

The Plot2d component enables the user to do basic 2D plotting as an overlay item in the view. 

This tutorial creates a simple overlay plot to the view and adds two curves.

.. note::
    This tutorial expect the application to have a correctly configured :class:`cee::vis::View`
    in place. See demo applications on how to set up a :class:`cee::vis::View` in your application.

**Create plot data**

Create the value arrays for the two curves. In this case, the x-values are the same for 
both curves and are reused.

.. literalinclude:: ../../../../EnvisionDesktop/Tutorials/Plot.cpp
    :language: cpp
    :lines: 38-43

**Create plot**

Create the plot as an overlay item and add both curves.

.. literalinclude:: ../../../../EnvisionDesktop/Tutorials/Plot.cpp
    :language: cpp
    :lines: 45-49

**Add to view**

Add the overlay plot item to the view.

.. literalinclude:: ../../../../EnvisionDesktop/Tutorials/Plot.cpp
    :language: cpp
    :lines: 51-53

**See the complete source code here:**

:ref:`plot-example`

