def _testBasic(): print "Init" Nutmeg.init() print "Sending Figure" fig = Nutmeg.figure('fig', "figure1.qml") print "Sending Data" fig.set('ax[1].red.y', np.random.standard_normal(10))
def _testFonts(): Nutmeg.init() fig = Nutmeg.figure('fig', 'figureFont.qml') fig.set('ax[1].red.y', np.random.standard_normal(10)) # fig.set('ax[1].title', "Axis2") for i in range(3): fig.set('ax[' + str(i) + '].title', "Axis" + str(i+1))
def _testImages(): import cv2 Nutmeg.init() fig = Nutmeg.figure('fig', "figureIm.qml") im = open("img.jpg") imData = im.read() fig.set('ax.im.binary', imData)
def _testButton(): Nutmeg.init() fig = Nutmeg.figure('fig', 'figure_single.qml') fig.setGui('gui1.qml') print (fig.parameters) time.sleep(0.1) buttonParam = fig.parameter("button") while True: if buttonParam.changed: changes = buttonParam.changed print("Button: %d (clicked %d times)" % (changes, buttonParam.read())) break time.sleep(0.1)
def _testParams(): Nutmeg.init() fig = Nutmeg.figure('fig', 'figure1.qml') print "Sending GUI..." success = fig.setGui('gui1.qml') N = 100 data = np.random.standard_normal((3, N*10)) data2 = np.random.standard_normal((3, N)) update = lambda params: applyBlur(data, params['sigma']) update2 = lambda params: applyBlur(data2, params['sigma']) fig.set('ax[:].blue.x', np.arange(N*10,dtype=float)/10) fig.set('ax[:].red.x', np.arange(N, dtype=float)) fig.set('ax[:].blue.y', Updater(['sigma'], update=update)) fig.set('ax[:].red.y', Updater(['sigma'], update=update2)) # for i in range(100): # fig.set('ax[:].red', update2({'sigma': i*0.05})) # time.sleep(0.025) print("Data set")
def _testValidateHandle(): Nutmeg.init() fig = Nutmeg.figure('fig', 'figure_single.qml') print(Nutmeg.isValidHandle('fig.ax.redPlot'))
def customBar(): fig = Nutmeg.figure('customBar', 'customBarPlot.qml') fig.set('ax.barPlot', data=[1,2,3,-0.5,7], barWidth=1.5, spacing=3)
def _testGrid(): Nutmeg.init() fig = Nutmeg.figure('fig', 'figureGrid.qml') fig.set('ax[1].red.y', np.random.standard_normal(10))
# Code starts import Nutmeg import numpy as np # Initialise the Nutmeg module. This connects to the core. Nutmeg.init() # Create the figure from a qml file fig = Nutmeg.figure('basic02', "figure_triple.qml") # Set the data randomData = np.random.standard_normal(10) fig.set('ax[1].red.y', randomData) x = np.r_[0:10.:0.01] ySin = np.sin(x) fig.set('ax[0].green', {'x': x, 'y': ySin}) yTan = np.tan(x) fig.set('ax[2].blue', {'x': x, 'y': yTan})
def customAdvancedBar(): fig = Nutmeg.figure('customAdvancedBar', 'customAdvancedBarPlot.qml') fig.set('ax.barPlot', data=[[1, 2, 3, -2, 0.5, 6, 1], [-0.5, 7]], barWidth=1) fig.set('legend', labels=["Hey", "There", "Labels", "I", "Love", "Lamp"])
def _testDelta(): Nutmeg.init() fig = Nutmeg.figure('fig', 'figure1.qml') fig.set('ax[1].red.y', np.random.standard_normal(10)) fig.set('ax[1].red.y[5]', -10)
import Nutmeg from numpy import sin, cos, pi, r_ # Assuming the core is on port 43686 (default) Nutmeg.init() x = r_[0:1:0.01] y1 = sin(10*pi*x) y2 = 10*pi*cos(10*pi*x) fig = Nutmeg.figure("myFigure", "myFigure.qml") fig.set("axis1.data", x=x, y=y1) fig.set("axis2.data", x=x, y=y2)
def basics(): Nutmeg.figure('basicCanvas', 'canvasPlotBasic.qml')
# Code starts import Nutmeg import numpy as np # Initialise the Nutmeg module. This connects to the core. Nutmeg.init() # Create the figure from a qml file fig = Nutmeg.figure('basic01', "figure_single.qml") # Set the data randomData = np.random.standard_normal(10) fig.set('ax.redPlot.bars', randomData) x = np.r_[0:10.:0.01] ySin = np.sin(x) fig.set('ax.greenPlot', {'x': x, 'y': ySin}) yTan = np.tan(x) fig.set('ax.bluePlot', {'x': x, 'y': yTan})
def customAdvancedBar(): fig = Nutmeg.figure('customAdvancedBar', 'customAdvancedBarPlot.qml') fig.set('ax.barPlot', data=[[1,2,3, -2,0.5,6,1],[-0.5,7]], barWidth=1) fig.set('legend', labels=["Hey", "There", "Labels", "I", "Love", "Lamp"])
# Code starts import Nutmeg import numpy as np # Initialise the Nutmeg module. This connects to the core. Nutmeg.init() # Create the figure from a qml file fig = Nutmeg.figure('fig', "figure1.qml") # Set the data randomData = np.random.standard_normal(10) fig.set('ax[1].red.y', randomData) x = np.r_[0:10.:0.01] ySin = np.sin(x) fig.set('ax[0].green', {'x': x, 'y': ySin}) yTan = np.tan(x) fig.set('ax[2].blue', {'x': x, 'y': yTan})
def customBar(): fig = Nutmeg.figure('customBar', 'customBarPlot.qml') fig.set('ax.barPlot', data=[1, 2, 3, -0.5, 7], barWidth=1.5, spacing=3)
import Nutmeg import time from scipy import ndimage import numpy as np # Init the figure Nutmeg.init() fig = Nutmeg.figure('paramExample', 'figure1.qml') # Set the GUI as described in the qml file success = fig.setGui('gui1.qml') sigmaParam = fig.parameter("sigma") N = 100 data = np.random.standard_normal((3, N*10)) def applyBlur(dataIn, sigma): return ndimage.gaussian_filter1d(dataIn, sigma, axis=1) while True: if sigmaParam.changed: sigma = sigmaParam.read() print "Sigma Changed:", sigma dataBlur = applyBlur(data, sigma) fig.set('ax.blue', y=dataBlur)
import Nutmeg Nutmeg.init() fig = Nutmeg.figure('imageExample', "figureIm.qml") im = open("img.jpg") imData = im.read() fig.set('ax.im.binary', imData) fig.set('ax.data', {'x': [0, 1, 2, 800, 1500], 'y': [0, 500, 100, 800, 1000]}) # fig.set('ax.data2', {'x': [0, 1, 2, 800, 1500], 'y': [0, 300, 200, 900, 1000]})