def __init__(self): self.addedData = [] print(matplotlib.__version__) # The data self.xlim = 200 self.n = np.linspace(0, self.xlim - 1, self.xlim) a = [] b = [] a.append(2.0) a.append(4.0) a.append(2.0) b.append(4.0) b.append(3.0) b.append(4.0) self.y = (self.n * 0.0) + 50 # The window self.fig = Figure(figsize=(5, 5), dpi=100) self.ax1 = self.fig.add_subplot(111) # self.ax1 settings self.ax1.set_xlabel('time') self.ax1.set_ylabel('raw data') self.line1 = Line2D([], [], color='blue') self.line1_tail = Line2D([], [], color='red', linewidth=2) self.line1_head = Line2D([], [], color='red', marker='o', markeredgecolor='r') self.ax1.add_line(self.line1) self.ax1.add_line(self.line1_tail) self.ax1.add_line(self.line1_head) self.ax1.set_xlim(0, self.xlim - 1) self.ax1.set_ylim(0, 100) FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval=50, blit=True) return
def _step(self, *args): # Extends the _step() method for the TimedAnimation class. try: TimedAnimation._step(self, *args) except Exception as e: TimedAnimation._stop(self) pass
def _step(self, *args): try: TimedAnimation._step(self, *args) except Exception: self.abc += 1 print(str(self.abc)) TimedAnimation._stop(self)
def __init__(self, model, max_frames=100, interval=100): self.max_frames = max_frames self.model = model self.lines = dict() self.node_pos = nx.spring_layout(self.model.get_graph()) self.create_figure() TimedAnimation.__init__(self, self.fig, interval, blit=True)
def __init__(self, xlim, ylim, width, height, resolution): self.data1 = [] self.data2 = [] # the data self.xlim = 200 self.n = np.linspace(0, self.xlim - 1, self.xlim) self.y1 = self.n * 0.0 self.y2 = self.n * 0.0 # the window self.fig = Figure(figsize=(width, height), dpi=resolution) self.ax1 = self.fig.add_subplot(211) self.ax2 = self.fig.add_subplot(212) # Plot 1 settings self.line1 = Line2D([], [], color='blue') self.ax1.add_line(self.line1) self.ax1.set_xlim(xlim[0], xlim[1]) self.ax1.set_ylim(ylim[0], ylim[1]) self.ax1.set_title("Atrial") self.ax1.set_xlabel("Time") self.ax1.set_ylabel("Voltage (V)") self.line2 = Line2D([], [], color='red') self.ax2.add_line(self.line2) self.ax2.set_xlim(xlim[0], xlim[1]) self.ax2.set_ylim(ylim[0], ylim[1]) self.ax2.set_title("Ventricular") self.ax2.set_xlabel("Time") self.ax2.set_ylabel("Voltage (V)") FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval=50, blit=True)
def __init__(self, title): self.pause = 0 self.addedData = [] self.exceptCount = 0 self.autoZoom = False print(matplotlib.__version__) # The data self.xlim = 1000 self.n = np.linspace(-(self.xlim - 1), 0, self.xlim) self.y = (self.n * 0.0) # The window self.fig = Figure(figsize=(5,5), dpi=100) self.ax1 = self.fig.add_subplot(111) # self.ax1 settings self.ax1.set_xlabel('samples') self.ax1.set_ylabel('data') self.ax1.set_title(title) self.line1 = Line2D([], [], color='blue') self.line1_tail = Line2D([], [], color='red', linewidth=2) self.line1_head = Line2D([], [], color='red', marker='o', markeredgecolor='r') self.ax1.add_line(self.line1) self.ax1.add_line(self.line1_tail) self.ax1.add_line(self.line1_head) self.ax1.set_xlim(-(self.xlim - 1),0) self.ax1.set_ylim(-100, 100) self.ax1.grid() self.firstUpdatedData = True FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval = 50, blit = True) return
def __init__(self, stockFrame): self.addedData = [] self.yLine = [] self.line = [] self.line_head = [] self.stockFrame = stockFrame # self.line_tail = [] global line line = self.line # print(matplotlib.__version__) # The data self.xlim = 200 self.n = np.linspace(0, self.xlim - 1, self.xlim) # The window self.fig = Figure(figsize=(5,3), dpi=100) self.ax1 = self.fig.add_subplot(111) global ax1 ax1 = self.ax1 # self.ax1 settings self.ax1.set_xlabel('time') self.ax1.set_ylabel('price') self.ax1.set_xlim(0, self.xlim - 1) self.ax1.set_ylim(0, 10) FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval = 50, blit = False)
def __init__(self): self.addedData = [] print(matplotlib.__version__) # The data self.xlim = 2048 self.n = np.linspace(0, self.xlim - 1, self.xlim) self.y = epics.caget("BL7D:dxpXMAP:mca1") # The window self.fig = Figure(figsize=(5, 5), dpi=75) self.ax1 = self.fig.add_subplot(111) self.ax1.grid() self.ax1.hold(False) # self.ax1 settings self.ax1.set_xlabel('bins') self.ax1.set_ylabel('count data') self.line1 = Line2D([], [], color='blue') self.line1_tail = Line2D([], [], color='red', linewidth=1) self.line1_head = Line2D([], [], color='red', marker='o', markeredgecolor='r') self.ax1.add_line(self.line1) self.ax1.add_line(self.line1_tail) self.ax1.add_line(self.line1_head) FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval=300, blit=True)
def __init__(self, fig): # Instance variables for storing plotting # information. With exception to self.fig, # most of the variables will be filled in # after the constructor has been initialized. self.boards_to_animate = dict() self.axes_to_animate = dict() self.line_of_axes = dict() self.shot_len = int() self.fig = fig self.label_txt = object() self.shot_label = object() self.board_names = dict() # Instance variables for stopping the animation self.pause = False self.stop_btn = object() self.display_state = StringVar() # Instance variable for stepping the animation # forward and backward self.step_up_dwn = object() self.frame_seq = object() self.current_frame = None TimedAnimation.__init__(self, self.fig, interval=1000, blit=False)
def __init__(self, port): self.n = np.linspace(0, 1, 1) self.abc = 1 self.sensors = Sensors(port) self.sensors_port = self.sensors.port self.sensors.flush() self.temp_yar = [0] self.humidity_yar = [0] self.smoke_conc = [0] self.time_ar = [0] self.current_temp_1 = 0 self.current_temp_2 = 0 self.current_hum_1 = 0 self.current_hum_2 = 0 self.current_smoke_concentration = 0 # Set up figure self.fig = Figure(figsize=(4, 12), dpi=80) self.fig.suptitle("Sensor Data") self.fig.subplots_adjust(wspace=0.4) FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval=2000, blit=True)
def __init__(self): self.addedData = [] self.Criteria_TTC = 2.6 print('Matplotlib Version:', matplotlib.__version__) # The data self.xlim = 30 self.n = np.linspace(0, self.xlim - 1, self.xlim) self.y = (self.n * 0.0) + 0 # The window self.fig = Figure(figsize=(5, 5), dpi=100) self.ax1 = self.fig.add_subplot(111) # self.ax1 settings self.ax1.set_xlabel('time') self.ax1.set_ylabel('TTC') self.line1 = Line2D([], [], color='blue', label='TTC') self.line1_tail = Line2D([], [], color='blue', linewidth=2) self.line1_head = Line2D([], [], color='black', marker='o', markeredgecolor='k') self.Criteria_TTC_line = Line2D([], [],color='red', label = 'Criteria TTC') self.ax1.add_line(self.line1) self.ax1.add_line(self.line1_tail) self.ax1.add_line(self.line1_head) self.ax1.add_line(self.Criteria_TTC_line) self.ax1.set_xlim(0, self.xlim - 1) self.ax1.set_ylim(0, 15) self.ax1.grid(True) self.ax1.legend() FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval= 1, blit=True)
def __init__(self): added_data_all = [] for c in range(plots_count): added_data_all.append([]) self.added_data_all = added_data_all print(matplotlib.__version__) self.xlim = 200 self.n = np.linspace(0, self.xlim - 1, self.xlim) self.fig = Figure(figsize=(5, 8), dpi=100) y_all = [] ax_all = [] line_all = [] line_tail_all = [] line_head_all = [] for c in range(plots_count): y_all.append(self.n * 0.0) ax = self.fig.add_subplot(plots_count, 1, c + 1) ax.set_xlabel(str(c)) ax.set_ylabel(ch_names[c], rotation='horizontal', labelpad=-60, ha='left') line = Line2D([], [], color='blue', linewidth=1) line_tail = Line2D([], [], color='red', linewidth=1) line_head = Line2D([], [], color='red', marker='o', markeredgecolor='r') line_all.append(line) line_tail_all.append(line_tail) line_head_all.append(line_head) ax.add_line(line) ax.add_line(line_tail) ax.add_line(line_head) ax.set_xlim(0, self.xlim - 1) ax.set_ylim(y_lims[c]) ax.set_yscale('log') ax_all.append(ax) self.y_all = y_all self.ax_all = ax_all self.line_all = line_all self.line_tail_all = line_tail_all self.line_head_all = line_head_all FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval=50, blit=True) return
def _step(self, *args): # Extends the _step() method for the TimedAnimation class. try: TimedAnimation._step(self, *args) except Exception as e: self.abc += 1 log(str(self.abc)) TimedAnimation._stop(self)
def _step(self, *args): # Extends the _step() method for the TimedAnimation class. try: TimedAnimation._step(self, *args) except Exception: self.abc += 1 # logging.info(str(self.abc)) TimedAnimation._stop(self) pass
def __init__(self): self.addedData = [] log("" + matplotlib.__version__) # The data self.xlim = XLIMIT self.ylim = YLIMIT self.n = np.linspace(0, self.xlim - 1, self.xlim) self.ny = np.linspace(0, self.ylim - 1, self.ylim) self.y = (self.ny * 0.0) + YOFFSET # The window self.fig = Figure(figsize=(5, 5), dpi=100) self.ax1 = self.fig.add_subplot(111) # configure grid layout major_ticks = np.arange(0, GRID_SIZE, GRID_MAYOR) minor_ticks = np.arange(0, GRID_SIZE, GRID_MINOR) self.ax1.set_xticks(major_ticks) self.ax1.set_xticks(minor_ticks, minor=True) self.ax1.set_yticks(major_ticks) self.ax1.set_yticks(minor_ticks, minor=True) # {'-', '--', '-.', ':', '', (offset, on-off-seq), ...} self.ax1.grid(color=GRID_COLOR[0], linestyle="-.", linewidth=1, which="both") self.ax1.set_facecolor(BACKGROUND_COLOR) # Different settings for the grids: self.ax1.grid(which='minor', alpha=ALPHA_MINOR) self.ax1.grid(which='major', alpha=ALPHA_MAYOR) # self.ax1 settings self.ax1.set_xlabel('time') self.ax1.set_ylabel('raw data') self.ax1.set_yscale("linear") self.line1 = Line2D([], [], color=PEN1_COLOR) self.line1_tail = Line2D([], [], color=PAINT_COLOR, linewidth=2) self.line1_head = Line2D([], [], color=PAINT_COLOR, marker='o', markeredgecolor=PAINT_COLOR[0]) self.ax1.add_line(self.line1) self.ax1.add_line(self.line1_tail) self.ax1.add_line(self.line1_head) self.resetXY(False) FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval=REFRESH_TIME, blit=True)
def _step(self, *args): """ Extends the _step() method for the TimedAnimation class.""" try: TimedAnimation._step(self, *args) except Exception as e: self.abc += 1 print(str(self.abc)) TimedAnimation._stop(self) pass return
def __init__(self, xlim, ylim, n): n_head = 10 self.addedY, self.addedX = [], [] logging.debug("Matplotlib Version:" + matplotlib.__version__) self.xlim, self.ylim = xlim, ylim # The data self.n = np.linspace(0, n - 1, n) # The window self.fig = Figure(figsize=(5, 5), dpi=100) self.ax1 = self.fig.add_subplot(111) # self.ax1 settings self.ax1.set_xlabel("Longitude") self.ax1.set_ylabel("Latitude") self.points_blue = Line2D([], [], marker="o", linewidth=0, color="0.5") self.ax1.add_line(self.points_blue) self.lines_red = [] a = list(np.logspace(1, 0, 5) / 10) a += [0, 0, 0, 0, 0] a.reverse() for i in range(n_head): self.lines_red.append( Line2D([], [], color="red", linewidth=4, alpha=a[i])) self.lines_gray = Line2D([], [], color="0.5", linewidth=1) self.points_red = Line2D([], [], color="red", marker="o", markeredgecolor="r", linewidth=0) self.ax1.add_line(self.points_red) self.ax1.add_line(self.points_blue) self.ax1.add_line(self.lines_gray) for line in self.lines_red: self.ax1.add_line(line) self.ax1.set_xlim(xlim[0], xlim[1]) self.ax1.set_ylim(ylim[0], ylim[1]) self.title = self.ax1.text( 0.15, 0.95, "", bbox={ "facecolor": "w", "alpha": 0.5, "pad": 5 }, transform=self.ax1.transAxes, ha="center", ) ratio = 1.0 xleft, xright = self.ax1.get_xlim() ybottom, ytop = self.ax1.get_ylim() self.ax1.set_aspect(abs((xright - xleft) / (ybottom - ytop)) * ratio) FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval=400, blit=True)
def _step(self, *args): # Extends the _step() method for the TimedAnimation class. try: TimedAnimation._step(self, *args) except Exception as e: self.exceptCount += 1 print(str(self.exceptCount)) TimedAnimation._stop(self) pass return
def __init__(self): self.addedData = [] self.subplots = [] self.lines = [] self.line_heads = [] self.line_tails = [] print(matplotlib.__version__) # The data self.xlim = 200 self.n = np.linspace(0, self.xlim - 1, self.xlim) a = [] b = [] a.append(2.0) a.append(4.0) a.append(2.0) b.append(4.0) b.append(3.0) b.append(4.0) self.y = [] for i in range(CHANNELS_NUMBER): self.y.append((self.n * 0.0) + 50) # The window self.fig = Figure(figsize=(5, 5), dpi=100) self.subplots = [] for i in range(CHANNELS_NUMBER): line = Line2D([], [], color='blue') line_tail = Line2D([], [], color='red', linewidth=2) line_head = Line2D([], [], color='red', marker='o', markeredgecolor='r') subplot = self.fig.add_subplot(CHANNELS_NUMBER, 1, i + 1) subplot.add_line(line) subplot.add_line(line_tail) subplot.add_line(line_head) subplot.set_xlim(0, self.xlim - 1) self.lines.append(line) self.line_heads.append(line_head) self.line_tails.append(line_tail) self.subplots.append(subplot) self.sample_num = 0 FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval=16, blit=True)
def __init__(self): # The window self.fig = Figure(figsize=(5, 5), dpi=100) self.ax1 = self.fig.add_subplot(111, projection='polar') self.offsets = [] # self.ax1 settings self.ax1.grid(True) self.line2 = self.ax1.scatter([0, 0], [0, 0], s=5, c=[0, 50], cmap=plt.cm.rainbow, lw=0) self.ax1.set_rmax(5000) FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval= 10, blit=True)
def _step(self, *args): """ Step through the animation or plot """ try: TimedAnimation._step(self, *args) except Exception as e: TimedAnimation._stop(self) pass
def __init__(self, maxlen=20): """ Class contstructor Param: maxlen: number of values in the plot window. This helps to avoid resizing of the window """ self._data = deque(maxlen=maxlen) # The data self._xlim = 200 self._n = np.linspace(0, self._xlim - 1, self._xlim) self._y = (self._n * 0.0) # The window self._fig = Figure(figsize=(5, 5), dpi=100) self._ax1 = self._fig.add_subplot(111) # self._ax1 settings self._ax1.set_xlabel('time') self._ax1.set_ylabel('raw data') self._line1 = Line2D([], [], color='blue') self._line1_tail = Line2D([], [], color='red', linewidth=2) self._line1_head = Line2D([], [], color='red', marker='o', markeredgecolor='r') self._ax1.add_line(self._line1) self._ax1.add_line(self._line1_tail) self._ax1.add_line(self._line1_head) self._ax1.set_xlim(0, self._xlim - 1) self._ax1.set_ylim(0, 100) FigureCanvas.__init__(self, self._fig) TimedAnimation.__init__(self, self._fig, interval=50, blit=True)
def __init__(self): self.addedDataX = [] self.addedDataY = [] self.addedDataZ = [] self.ylimRange = [-14,14] self.isZoomed = False # print(matplotlib.__version__) # data self.numberOfSamplesStored = 200 self.t = np.linspace(0, self.numberOfSamplesStored - 1, self.numberOfSamplesStored) self.x = (self.t * 0.0) self.y = (self.t * 0.0) self.z = (self.t * 0.0) # The window self.fig = Figure(figsize=(5,5), dpi=100) self.fig.patch.set_facecolor((0.92, 0.92, 0.92)) self.ax1 = self.fig.add_subplot(111) # self.ax1 settings self.ax1.set_ylabel('field XYZ') # line1 X self.line1 = Line2D([], [], color='blue') self.line1_tail = Line2D([], [], color='blue', linewidth=2) self.line1_head = Line2D([], [], color='blue', marker='o', markeredgecolor='blue') self.ax1.add_line(self.line1) self.ax1.add_line(self.line1_tail) self.ax1.add_line(self.line1_head) # line1 Y self.line2 = Line2D([], [], color='green') self.line2_tail = Line2D([], [], color='green', linewidth=2) self.line2_head = Line2D([], [], color='green', marker='o', markeredgecolor='green') self.ax1.add_line(self.line2) self.ax1.add_line(self.line2_tail) self.ax1.add_line(self.line2_head) # line1 Z self.line3 = Line2D([], [], color='red') self.line3_tail = Line2D([], [], color='red', linewidth=2) self.line3_head = Line2D([], [], color='red', marker='o', markeredgecolor='red') self.ax1.add_line(self.line3) self.ax1.add_line(self.line3_tail) self.ax1.add_line(self.line3_head) #lim self.ax1.set_xlim(0, self.numberOfSamplesStored - 1) self.ax1.set_ylim(self.ylimRange[0], self.ylimRange[1]) self.ax1.get_xaxis().set_visible(False) # init FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval = 50, blit = True)
def __init__(self, is_cool): self.addedData = [] self.subplots = [] self.lines = [] self.line_heads = [] self.line_tails = [] self.xlim = X_LIM self.n = np.linspace(0, self.xlim - 1, self.xlim) self.y = [] for i in range(CHANNELS_NUMBER): self.y.append((self.n * 0.0) + 50) self.fig = Figure(figsize=(5, 5), dpi=DPI) if is_cool: self.fig.set_facecolor(BACKGROUND_COLOR) self.subplots = [] for i in range(CHANNELS_NUMBER): palette = graph_palette_default line = Line2D([], [], color=palette[0], linewidth=3) line_tail = Line2D([], [], color=palette[1], linewidth=4) line_head = Line2D([], [], color=palette[2], marker='o', markeredgecolor='b') subplot = self.fig.add_subplot(CHANNELS_NUMBER, 1, i + 1) subplot.add_line(line) subplot.add_line(line_tail) subplot.add_line(line_head) subplot.set_xlim(0, self.xlim - 1) if is_cool: subplot.set_axis_off() self.lines.append(line) self.line_heads.append(line_head) self.line_tails.append(line_tail) self.subplots.append(subplot) self.sample_num = 0 FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval=REDRAW_INTERVAL, blit=True)
def __init__(self, speed): self.speed = speed #if self.speed == "medium": # interval = 100 #elif self.speed == "low": # interval = 100 self.addedData = None self.xlim = 200 self.fig = Figure(figsize=(8, 8), dpi=100) self.ax1 = self.fig.add_subplot(111) self.ax1.set_xlabel('Assets') self.ax1.set_ylabel('Weights') self.ax1.set_ylim(-0.1, 1.1) self.bar = None FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval=100, blit=False)
def __init__(self, strPort, bufferSize, lineSkip, console): # The data self.time = [] self.data = [] self.bufferSize = bufferSize self.lineSkip = lineSkip # The window self.fig = Figure(figsize=(5, 5), dpi=100) ax1 = self.fig.add_subplot(111) # ax1 settings ax1.set_xlabel('time') ax1.set_ylabel('raw data') self.console = console # The serial connection self.strPort = strPort self.ser = serial.Serial(strPort, 115200) print('reading from serial port %s...' % self.strPort) # get sample data print('initializing...') line = self.ser.readline() # Get float numbers by splitting line (by white-spaces) data = [float(val) for val in line.split()] colors = ['blue', 'red', 'black', 'green'] self.n_plots = len(data) - 1 self.lines = [] self.time = deque([data[0]]) for i in range(self.n_plots): self.data.append(deque([data[i + 1]])) self.lines.append( Line2D(self.time, self.data[-1], color=colors[i % 4])) ax1.add_line(self.lines[-1]) self.doPlot = True ax1.set_xlim(0, 1000) ax1.set_ylim(0, 4) self.axes = ax1 FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval=20, blit=True)
def __init__(self, sensor_name, sensor_units, sensor_min, sensor_max, raw_voltage, frequency): self.added_data = [] self.abc = 0 # The data self.xlim = ( 2 * 60 ) * frequency # Chart the past 2 minutes regardless of the frequency self.n = np.linspace(0, self.xlim - 1, self.xlim) self.y = (self.n * 0.0) + 50 # The window self.fig = Figure(figsize=(5, 5), dpi=75) self.ax1 = self.fig.add_subplot(111) # self.ax1 settings self.ax1.set_title(sensor_name) self.ax1.set_xlabel('datapoints') self.line1 = Line2D([], [], color='blue', linewidth=2) self.line1_tail = Line2D([], [], color='red', linewidth=2) self.line1_head = Line2D([], [], color='red', marker='o', markeredgecolor='r') self.ax1.add_line(self.line1) self.ax1.add_line(self.line1_tail) self.ax1.add_line(self.line1_head) self.ax1.set_xlim(0, self.xlim - 1) if raw_voltage: self.ax1.set_ylim(-12, 12) self.ax1.set_ylabel('V') self.ax1.yaxis.set_label_position("right") self.ax1.yaxis.tick_right() else: wiggle_room = (sensor_max - sensor_min) * .10 self.ax1.set_ylim(sensor_min - wiggle_room, sensor_max + wiggle_room) self.ax1.set_ylabel(sensor_units) self.ax1.yaxis.set_label_position("right") self.ax1.yaxis.tick_right() FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval=1, blit=True)
def __init__(self, data, legend, fig=None, **kwargs): # fig setup ... if not fig: fig = plt.figure() ax = fig.add_subplot(1, 1, 1) # data setup ... self._data = data n, m = np.shape(data)[:2] self._n = n self._m = m xmin = np.min(data[:, :, 0]) xmax = np.max(data[:, :, 0]) xmid = (xmax + xmin) / 2. ymin = np.min(data[:, :, 1]) ymax = np.max(data[:, :, 1]) ymid = (ymax + ymin) / 2. s = max(xmax - xmin, ymax - ymin) # circle radius r = 0.01 * s # plots setup ... self._ls = [] self._cs = [] for i in range(m): col = np.random.uniform(size=3) cir = plt.Circle((0, 0), r, fc=col) ln = Line2D([], [], color=col) self._cs.append(cir) self._ls.append(ln) ax.add_patch(cir) ax.add_line(ln) ax.set_aspect('equal') ax.set_xlim(xmid - s / 2., xmid + s / 2.) ax.set_ylim(ymid - s / 2., ymid + s / 2.) ax.set_xlabel('x') ax.set_ylabel('y') ax.legend(legend) TimedAnimation.__init__(self, fig, **kwargs)
def __init__(self): self.addedData = [] # The data self.xlim = 200 self.n = np.linspace(-self.xlim + 1, 0, self.xlim) self.y = self.n * 0.0 self.yy = self.n * 0.0 # The window self.fig = Figure(figsize=(5, 5), dpi=100) self.ax1 = self.fig.add_subplot(211) self.ax2 = self.fig.add_subplot(212, sharex=self.ax1) # self.ax1.get_shared_x_axes().join(self.ax1, self.ax2) # self.ax1 settings self.ax1.set_xlabel("time") self.ax1.get_yaxis().set_visible(False) # self.ax1.set_ylabel("") self.line1 = Line2D([], [], color="blue") self.line1_tail = Line2D([], [], color="blue", linewidth=2) self.line1_head = Line2D([], [], color="blue", marker=9, markeredgecolor="b") self.line2 = Line2D([], [], color="blue") self.line2_tail = Line2D([], [], color="red", linewidth=2) self.line2_head = Line2D([], [], color="red", marker=9, markeredgecolor="r") self.ax1.add_line(self.line1) self.ax1.add_line(self.line1_tail) self.ax1.add_line(self.line1_head) self.ax2.add_line(self.line2) self.ax2.add_line(self.line2_tail) self.ax2.add_line(self.line2_head) # self.ax2.set_xlim(-self.xlim + 1, 0) # self.ax2.set_ylim(-0.25, 1.25) self.ax1.set_xlim(-self.xlim + 1, 0) self.ax1.set_ylim(-0.25, 1.25) FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval=50, blit=True)
def __init__(self, strPort, bufferSize, lineSkip, console): # The data self.time = [] self.data = [] self.bufferSize = bufferSize self.lineSkip = lineSkip # The window self.fig = Figure(figsize=(5,5), dpi=100) ax1 = self.fig.add_subplot(111) # ax1 settings ax1.set_xlabel('time') ax1.set_ylabel('raw data') self.console = console # The serial connection self.strPort = strPort self.ser = serial.Serial(strPort, 115200) print('reading from serial port %s...' % self.strPort) # get sample data print('initializing...') line = self.ser.readline() # Get float numbers by splitting line (by white-spaces) data = [float(val) for val in line.split()] colors = ['blue','red','black','green'] self.n_plots = len(data)-1 self.lines = [] self.time = deque([data[0]]) for i in range(self.n_plots): self.data.append(deque([data[i+1]])) self.lines.append(Line2D(self.time, self.data[-1], color=colors[i%4])) ax1.add_line(self.lines[-1]) self.doPlot = True ax1.set_xlim(0, 1000) ax1.set_ylim(0, 4) self.axes = ax1 FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval = 20, blit = True)
def __init__(self): self.addedData = [] print(matplotlib.__version__) # The data self.xlim = 100 self.n = np.linspace(0, self.xlim - 1, self.xlim) self.ticks_lbl=['0' for i in range(self.xlim)] self.ticks_pos=[int(np.linspace(0, 99, 5)[i]) for i in range(5)] self.ticks_lbl_reduced=[self.ticks_lbl[pos] for pos in self.ticks_pos] a = [] b = [] a.append(2.0) a.append(4.0) a.append(2.0) b.append(4.0) b.append(3.0) b.append(4.0) self.y = (self.n * 0.0) + 50 # The window self.fig = Figure(figsize=(5,5), dpi=100) self.ax1 = self.fig.add_subplot(111) # self.ax1 settings self.ax1.set_xlabel('time') self.ax1.set_ylabel('raw data') self.line1 = Line2D([], [], color='blue') self.line1_tail = Line2D([], [], color='red', linewidth=2) self.line1_head = Line2D([], [], color='red', marker='o', markeredgecolor='r') self.ax1.add_line(self.line1) self.ax1.add_line(self.line1_tail) self.ax1.add_line(self.line1_head) self.ax1.set_xlim(0, self.xlim - 1) self.ax1.set_ylim(0, 250) self.ax1.set_xticklabels(self.ticks_lbl) FigureCanvas.__init__(self, self.fig) TimedAnimation.__init__(self, self.fig, interval = 50, blit = False)