{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# PyQtGraph Example\n\nBasic PyQtGraph example.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from qtpy import QtWidgets\nimport numpy as np\nimport pyqtgraph as pg\nimport pyqtgraph.opengl as gl"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Usually the first thing is to create a ``QApplication`` instance.  Some\nhigh-level functions do this for you, but you'll typically need to get the\napplication instance in order to call ``exec_()`` at the end of your script\nanyway.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "app = pg.mkQApp()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "A high-level plot call:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "pg.plot([1, 2, 3, 4, 5], [1, 4, 9, 16, 25])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "OpenGL examples won't generally work with a headless X server unfortunately:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "w = gl.GLViewWidget()\ng = gl.GLGridItem()\ndata = np.array([[0, 0, 0], [1, 0, 0], [1, 0, 1], [0, 0, 2]])\nsp = gl.GLScatterPlotItem(pos=data, color=(1, 1, 1, 1), size=10)\n\nw.addItem(g)\nw.addItem(sp)\nw.show()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "if __name__ == \"__main__\":\n    app.exec_()"
      ]
    }
  ],
  "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.7.9"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}