Examples

PlotNd visualization of a 3D array

 1from mpl_qt_viz.visualizers import PlotNd
 2import numpy as np
 3from PyQt5.QtWidgets import QApplication
 4import sys
 5
 6# Generate a 3-dimensional dimension array with numpy.meshgrid.
 7# The Plot Nd Widget supports higher dimensionality as well.
 8x = np.linspace(0, 1, num=75)
 9y = np.linspace(0, 1, num=100)
10z = np.linspace(0, 3, num=40)
11X, Y, Z = np.meshgrid(x, y, z)
12# Create a 3-dimensional example data array.
13arr = np.sin(2 * np.pi * 1 * Z) + .5 * X + np.cos(2 * np.pi * 4 * Y)
14
15#Run an application with the PlotNd widget
16app = QApplication(sys.argv)
17p = PlotNd(data=arr,
18           names=('Dim1', 'D2', 'D3'),  # Manually sets how each dimension is labeled.
19           indices=[y, x, z])  # Specifies the data range for each dimension.
20p.setColorMap('plasma')
21sys.exit(app.exec_())
_images/plotNdExample.gif

MultiPlot containing various images and line plots

 1import sys
 2import matplotlib.pyplot as plt
 3from PyQt5.QtWidgets import QApplication
 4import numpy as np
 5from mpl_qt_viz.visualizers import MultiPlot
 6
 7app = QApplication(sys.argv)
 8
 9# Generate a list of lists of artists and create a new MultiPlot with them.
10ims = [[plt.imshow(np.random.random((512, 512))), plt.text(100, 100, str(i))] for i in range(3)]
11mp = MultiPlot(ims, "Images")
12
13#Adjust the figure and axes
14plt.gcf().subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, hspace=0)
15mp.ax.get_xaxis().set_visible(False)
16mp.ax.get_yaxis().set_visible(False)
17mp.show()  # Show the widget
18
19#Create a second MultiPlot with line plots
20fig, ax = plt.subplots()
21lines = [ax.plot(np.random.random((50,))) for i in range(3)]
22mp2 = MultiPlot(lines, 'Lines')
23mp2.show()
24
25sys.exit(app.exec())
todo

Add example of ROI drawing tools.