{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fa151629",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pyqtgraph as pg\n",
    "import numpy as np\n",
    "from pyqtgraph.jupyter import PlotWidget\n",
    "\n",
    "pg.mkQApp()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3c28c27d",
   "metadata": {},
   "outputs": [],
   "source": [
    "pw1 = PlotWidget()\n",
    "pw1.plot(np.arange(10))\n",
    "pw1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9a2fe974",
   "metadata": {},
   "outputs": [],
   "source": [
    "pw2 = PlotWidget()\n",
    "pditem = pw2.plot()\n",
    "x = np.linspace(-3, 3, 1000)\n",
    "data = np.sinc(x)\n",
    "pditem.setData(data)\n",
    "pw2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8644cd6f",
   "metadata": {},
   "outputs": [],
   "source": [
    "pw3 = PlotWidget()\n",
    "imgitem = pg.ImageItem(axisOrder='row-major')\n",
    "pw3.addItem(imgitem)\n",
    "x = np.linspace(-3, 3, 1000)\n",
    "y = np.linspace(-3, 3, 1000)\n",
    "data = np.sinc(y)[:,None] * np.sinc(x)\n",
    "imgitem.setImage(data)\n",
    "\n",
    "limits = data.min(), data.max()\n",
    "# bar = pw3.addColorBar( imgitem, colorMap='viridis', values=limits, limits=limits, rounding=0.1)\n",
    "cmap = pg.colormap.get('viridis')\n",
    "bar = pg.ColorBarItem(values=limits, colorMap=cmap, limits=limits, rounding=0.1)\n",
    "bar.setImageItem(imgitem, insert_in=pw3.getPlotItem())\n",
    "bar.sigLevelsChanged.connect(pw3.request_draw)\n",
    "bar.sigLevelsChangeFinished.connect(pw3.request_draw)\n",
    "\n",
    "pw3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f695e828",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
