def onPlotTimeDep(self, e=None, *args, **kargs): def plot_data(time, data): x = np.array(time, dtype='float').flatten() y = np.array(data, dtype='float').flatten() x = [t for t in x if not np.isnan(t)] y = [t for t in y if not np.isnan(t)] return np.array(x), np.array(y) help = self.td._var0._help data = self.td._var0 import ifigure.interactive as plt plt.figure() time = data['18']['data'] new_plot = True for key in help: if not key in data: continue if key == '18': continue x, y = help[key] if y.startswith('-'): if not new_plot: plt.addpage() try: xdata, ydata = plot_data(time, data[key]['data']) plt.plot(xdata, ydata) plt.title(x) new_plot = False except: print('failed to generate picture for', key) new_plot = True pass
def onSlice(self, event): from ifigure.interactive import figure, plot, nsec, isec, update, title, xlabel, ylabel if event.mpl_xydata[0] is None: return app = self.get_root_parent().app data1, data2 = self.get_slice(event.mpl_xydata[0], event.mpl_xydata[1]) if data1 is None: return if data2 is None: return from ifigure.widgets.book_viewer import BookViewer book, viewer = app.open_newbook_in_newviewer(BookViewer) book.get_page(0).set_section(2) ou = update() isec(0) plot(data1[0], data1[1]) title('x slice : y = '+str(event.mpl_xydata[1])) xlabel('x') isec(1) plot(data2[0], data2[1]) title('y slice : x = '+str(event.mpl_xydata[0])) xlabel('y') update(ou)
def specgram_demo(): ''' the demo in matplotlib. But calls interactive.specgram ''' from pylab import arange, sin, where, logical_and, randn, pi dt = 0.0005 t = arange(0.0, 20.0, dt) s1 = sin(2*pi*100*t) s2 = 2*sin(2*pi*400*t) # create a transient "chirp" mask = where(logical_and(t>10, t<12), 1.0, 0.0) s2 = s2 * mask # add some noise into the mix nse = 0.01*randn(len(t)) x = s1 + s2 + nse # the signal NFFT = 1024 # the length of the windowing segments Fs = int(1.0/dt) # the sampling frequency from ifigure.interactive import figure, specgram, nsec, plot, isec, clog, hold figure() hold(True) nsec(2) isec(0) plot(t, x) isec(1) specgram(x, NFFT=NFFT, Fs=Fs, noverlap=900) clog()
def onSlice(self, event): from ifigure.interactive import figure, plot, nsec, isec, update, title, xlabel, ylabel if event.mpl_xydata[0] is None: return for a in self._artists: axes = a.axes if axes is None: return data1, data2 = self.get_slice(event.mpl_xy[0], event.mpl_xy[1], a) if data1 is None: continue if data2 is None: continue figure() nsec(2) ou = update() isec(0) plot(data1[0], data1[1]) title('y slice : y = '+str(event.mpl_xydata[1])) xlabel('x') isec(1) plot(data2[0], data2[1]) title('x slice : x = '+str(event.mpl_xydata[0])) xlabel('y') update(ou)
def spec_demo(): ''' the demo in matplotlib. But calls interactive.specgram ''' from pylab import arange, sin, where, logical_and, randn, pi dt = 0.0005 t = arange(0.0, 20.0, dt) s1 = sin(2 * pi * 100 * t) s2 = 2 * sin(2 * pi * 400 * t) # create a transient "chirp" mask = where(logical_and(t > 10, t < 12), 1.0, 0.0) s2 = s2 * mask # add some noise into the mix nse = 0.01 * randn(len(t)) x = s1 + s2 + nse # the signal NFFT = 1024 # the length of the windowing segments Fs = int(1.0 / dt) # the sampling frequency from ifigure.interactive import figure, spec, nsec, plot, isec, clog, hold figure() hold(True) nsec(2) isec(0) plot(t, x) isec(1) spec(t, x, NFFT=NFFT, noverlap=900) clog()
def plot_tiles3(): x, y, z = read_tile_data(list=True) figure() threed('on') hold('on') for k in range(100): m = k + 100 plot(x[m], y[m], z[m], facecolor=[1, 0, 0, 1])
def plot_tiles(): ''' line plot of tile data ''' x, y, z = read_tile_data() figure() threed('on') plot(x, y, z)
def plot_tiles3(): x, y, z = read_tile_data(list = True) figure() threed('on') hold('on') for k in range(100): m = k+100 plot(x[m], y[m], z[m], facecolor = [1, 0, 0, 1])
""" # ** Template for a new script ** # Following variabs/functions can be used # obj : script object # top. proj : = obj.get_root_parent() # wdir : proj.getvar('wdir') # model: target model to work on # param : model param # app : proj.app (ifigure application) # exit() : exit from script # stop() : exit from script due to error # # args : parameter arguments passed to Run method (default = ()) # kwagrs : keyward arguments passed to Run method (default = {}) import numpy as np import ifigure.interactive as plt def example(): import numpy as np x = np.linspace(0, 6.28) y = np.sin(x) return x, y x, y = example() plt.addpage() plt.plot(x, y)
def plot_tiles2(): x, y, z = read_tile_data() figure() threed('on') plot(x, y, z, facecolor=[1, 0, 0, 1])
def plot_tiles2(): x, y, z = read_tile_data() figure() threed('on') plot(x, y, z, facecolor = [1, 0, 0, 1])