{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Embed in GTK3 with a navigation toolbar\n\nDemonstrate NavigationToolbar with GTK3 accessed via pygobject.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import gi\n\ngi.require_version('Gtk', '3.0')\nfrom gi.repository import Gtk\n\nimport numpy as np\n\nfrom matplotlib.backends.backend_gtk3 import NavigationToolbar2GTK3 as NavigationToolbar\nfrom matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas\nfrom matplotlib.figure import Figure\n\nwin = Gtk.Window()\nwin.connect(\"delete-event\", Gtk.main_quit)\nwin.set_default_size(400, 300)\nwin.set_title(\"Embedded in GTK3\")\n\nfig = Figure(figsize=(5, 4), dpi=100)\nax = fig.add_subplot(1, 1, 1)\nt = np.arange(0.0, 3.0, 0.01)\ns = np.sin(2*np.pi*t)\nax.plot(t, s)\n\nvbox = Gtk.VBox()\nwin.add(vbox)\n\n# Add canvas to vbox\ncanvas = FigureCanvas(fig)  # a Gtk.DrawingArea\nvbox.pack_start(canvas, True, True, 0)\n\n# Create toolbar\ntoolbar = NavigationToolbar(canvas)\nvbox.pack_start(toolbar, False, False, 0)\n\nwin.show_all()\nGtk.main()"
      ]
    }
  ],
  "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.14.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}