
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "_auto_examples/plot_background.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download__auto_examples_plot_background.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr__auto_examples_plot_background.py:


Generate the splinebox documentation background
-----------------------------------------------

This example shows how the background of the splinebox documentation is made.

.. GENERATED FROM PYTHON SOURCE LINES 7-43



.. image-sg:: /_auto_examples/images/sphx_glr_plot_background_001.png
   :alt: plot background
   :srcset: /_auto_examples/images/sphx_glr_plot_background_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np
    import splinebox
    import splinebox.basis_functions
    import splinebox.spline_curves

    knots = np.array([[0, 1], [0.1, 0.9], [0.2, 0.8], [0.6, 0.7], [0.35, 0.4], [0.8, 0.2], [0.9, 0.1], [1, 0]])
    M = len(knots)

    spline = splinebox.Spline(M=M, basis_function=splinebox.B3(), closed=False)
    spline.knots = knots

    ts = np.linspace(0, M - 1, 100)

    fig = plt.figure(frameon=False)
    fig.set_size_inches(2, 2)
    ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0])
    ax.axis("equal")
    ax.set_axis_off()
    fig.add_axes(ax)
    control_points = np.clip(spline.control_points, 0, 1)
    # for the actual background alpha=0.07 was used
    alpha = 1
    ax.plot(
        control_points[1:-1, 0],
        control_points[1:-1, 1],
        "-o",
        color="forestgreen",
        linewidth=1,
        markersize=1,
        alpha=alpha,
    )
    vals = spline(ts)
    ax.plot(vals[:, 0], vals[:, 1], "-", color="forestgreen", linewidth=1, alpha=alpha)
    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 0.013 seconds)


.. _sphx_glr_download__auto_examples_plot_background.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_background.ipynb <plot_background.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_background.py <plot_background.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_background.zip <plot_background.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
