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

.. only:: html

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

        Click :ref:`here <sphx_glr_download_gallery_plotting_scatter_histogram.py>`
        to download the full example code

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

.. _sphx_glr_gallery_plotting_scatter_histogram.py:


Scatter plot and histograms
===========================

A scatter plot of 2D points with matching histograms.

.. GENERATED FROM PYTHON SOURCE LINES 11-44



.. image-sg:: /gallery/plotting/images/sphx_glr_scatter_histogram_001.png
   :alt: scatter histogram
   :srcset: /gallery/plotting/images/sphx_glr_scatter_histogram_001.png
   :class: sphx-glr-single-img





.. code-block:: default


    import numpy as np

    import vispy.plot as vp

    np.random.seed(2324)
    n = 100000
    data = np.empty((n, 2))
    lasti = 0
    for i in range(1, 20):
        nexti = lasti + (n - lasti) // 2
        scale = np.abs(np.random.randn(2)) + 0.1
        scale[1] = scale.mean()
        data[lasti:nexti] = np.random.normal(size=(nexti-lasti, 2),
                                             loc=np.random.randn(2),
                                             scale=scale / i)
        lasti = nexti
    data = data[:lasti]


    color = (0.3, 0.5, 0.8)
    n_bins = 100

    fig = vp.Fig(show=False)
    line = fig[0:4, 0:4].plot(data, symbol='o', width=0,
                              face_color=color + (0.02,), edge_color=None,
                              marker_size=4)
    line.set_gl_state(depth_test=False)
    fig[4, 0:4].histogram(data[:, 0], bins=n_bins, color=color, orientation='h')
    fig[0:4, 4].histogram(data[:, 1], bins=n_bins, color=color, orientation='v')

    if __name__ == '__main__':
        fig.show(run=True)


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

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


.. _sphx_glr_download_gallery_plotting_scatter_histogram.py:


.. only :: html

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



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

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



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

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


.. only:: html

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

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