{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%gui qt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Scatter plot and histograms\n\nA scatter plot of 2D points with matching histograms.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\n\nimport vispy.plot as vp\n\nnp.random.seed(2324)\nn = 100000\ndata = np.empty((n, 2))\nlasti = 0\nfor i in range(1, 20):\n nexti = lasti + (n - lasti) // 2\n scale = np.abs(np.random.randn(2)) + 0.1\n scale[1] = scale.mean()\n data[lasti:nexti] = np.random.normal(size=(nexti-lasti, 2),\n loc=np.random.randn(2),\n scale=scale / i)\n lasti = nexti\ndata = data[:lasti]\n\n\ncolor = (0.3, 0.5, 0.8)\nn_bins = 100\n\nfig = vp.Fig(show=False)\nline = fig[0:4, 0:4].plot(data, symbol='o', width=0,\n face_color=color + (0.02,), edge_color=None,\n marker_size=4)\nline.set_gl_state(depth_test=False)\nfig[4, 0:4].histogram(data[:, 0], bins=n_bins, color=color, orientation='h')\nfig[0:4, 4].histogram(data[:, 1], bins=n_bins, color=color, orientation='v')\n\nif __name__ == '__main__':\n fig.show(run=True)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.19" } }, "nbformat": 4, "nbformat_minor": 0 }