{ "metadata": {}, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Matplotlib: pyside\n", "======================================================================\n", "\n", "This is a very basic example showing how to display a matplotlib plot\n", "within a Qt application using PySide. In case of problems try to change\n", "the rcParam entry \u201cbackend.qt4\u201d to \"PySide\" (e.g. by in the matplotlibrc\n", "file)." ] }, { "cell_type": "code", "collapsed": false, "input": [ "#!/usr/bin/env python\n", "import sys\n", "import matplotlib\n", "matplotlib.use('Qt4Agg')\n", "import pylab\n", "\n", "from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas\n", "from matplotlib.figure import Figure\n", "\n", "from PySide import QtCore, QtGui\n", "\n", "if __name__ == '__main__':\n", " app = QtGui.QApplication(sys.argv)\n", " \n", " # generate the plot\n", " fig = Figure(figsize=(600,600), dpi=72, facecolor=(1,1,1), edgecolor=(0,0,0))\n", " ax = fig.add_subplot(111)\n", " ax.plot([0,1])\n", " # generate the canvas to display the plot\n", " canvas = FigureCanvas(fig)\n", " \n", " win = QtGui.QMainWindow()\n", " # add the plot canvas to a window\n", " win.setCentralWidget(canvas)\n", " \n", " win.show()\n", " \n", " sys.exit(app.exec_())" ], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }