
If you omit this parameter, a new window is opened with the corresponding output.

This needs to be used in order to tell the figure where the Has got one further keyword-based parameter canvas. Once you added the itom-backend command as first, mandatory line to your script, the figure-class of matplotlib The click-events of both buttons is connected to the methods plotSine and plotDroppedSpines respectively.įor both button clicks the following things have to be done: close ( 3 )Īt the end of the script, the user interface matplotlibGui.ui is loaded and referenced by the variable gui. Therefore also tell # matplotlib to close this figure handle.

show () # if you call this script for the second time, the given figure-num (3) # is already in used for the lastly closed figure. connect ( "clicked()", plotDroppedSpines ) gui. show () gui = ui ( "matplotlibGui.ui", type = ui. figure ( num = 3, canvas = canvas ) ax = fig. plot #reference to matplotlibPlot widget fig = plt. show () def plotSine (): ''' plots sine, taken from matplotlib gallery examples ''' t = np. set_visible ( False ) # Only show ticks on the left and bottom spines ax. set_position (( 'outward', 10 )) # Hide the right and top spines ax. set_title ( 'dropped spines' ) # Move left and bottom spines outward by 10 points ax. use ( 'module://mpl_itom.backend_itomagg', False ) import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D def plotDroppedSpines (): ''' plot taken from matplotlib example 'spines_demo_dropped.py' ''' canvas = gui. When any of the both buttons are pressed, the following example should be displayed in the figure plot on the left side. In the following example, a new main window is created where a MatplotlibPlot widget (name: plot) is placed on the left side while two buttons (name: btnDroppedSpines and btnSine) are placed on the right side: Drag&Drop an instance of this widget onto your user interface. In the widget library of QtDesigner there is the widget MatplotlibPlot in the section itom Plugins (under the consumption that the corresponding designer plugin library is contained in the folder designer of the root directory of itom).
#PYPLOT COLORBAR OFFSETS SUBPLOT SIZE HOW TO#
For more information how to do this, see Creating customized dialogs, windows and dock widgets. Itom not only provides stand-alone windows for showing the result of the matplotlib, but it is also possible to integrate a matplotlib canvas into own user interfaces created by the Embedding a matplotlib figure in your own user interface ¶ This means, the library matplotlibPlot in the designer folder of itom is missing.įurther examples from the official matplotlib gallery are contained in the itom subfolder demo/matplotlib. If the figure does not appear, the matplotlib designer widget for itom is not available.

Embedding a matplotlib figure in your own user interface
