.. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_user_interfaces_embedding_in_gtk3_sgskip.py: ================= Embedding in GTK3 ================= Demonstrate adding a FigureCanvasGTK3Agg widget to a Gtk.ScrolledWindow using GTK3 accessed via pygobject. .. code-block:: default import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk from matplotlib.backends.backend_gtk3agg import ( FigureCanvasGTK3Agg as FigureCanvas) from matplotlib.figure import Figure import numpy as np win = Gtk.Window() win.connect("delete-event", Gtk.main_quit) win.set_default_size(400, 300) win.set_title("Embedding in GTK") fig = Figure(figsize=(5, 4), dpi=100) ax = fig.add_subplot(111) t = np.arange(0.0, 3.0, 0.01) s = np.sin(2*np.pi*t) ax.plot(t, s) sw = Gtk.ScrolledWindow() win.add(sw) # A scrolled window border goes outside the scrollbars and viewport sw.set_border_width(10) canvas = FigureCanvas(fig) # a Gtk.DrawingArea canvas.set_size_request(800, 600) sw.add(canvas) win.show_all() Gtk.main() .. _sphx_glr_download_gallery_user_interfaces_embedding_in_gtk3_sgskip.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: embedding_in_gtk3_sgskip.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: embedding_in_gtk3_sgskip.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature Keywords: matplotlib code example, codex, python plot, pyplot `Gallery generated by Sphinx-Gallery `_