def update(self, img_data): # Calculate and update ROI statistics. roi = img_data[self.cam.roi[1]:self.cam.roi[3], self.cam.roi[0]:self.cam.roi[2]] #np.save('roi.npy', roi) # for debugging try: self.roiTotalLbl.setText('%.0f' % np.sum(roi)) self.roiMeanLbl.setText('%.2f' % np.mean(roi)) self.roiMaxLbl.setText('%.0f' % np.max(roi)) self.roiMinLbl.setText('%.0f' % np.min(roi)) except: print("self.cam.roi:", self.cam.roi) print("roi:", roi) print("img_data:", img_data) # ROI histogram plot h_plot = self.roiHistWidget.get_plot() h_plot.del_all_items(except_grid=True) hist = make.histogram(roi.flatten(), 50) h_plot.add_item(hist) #print(hist.get_data()) h_plot.set_plot_limits(0, self.xHistLimBox.value(), 0, self.yHistLimBox.value()) h_plot.set_item_visible(hist, True) # Display ROI coordinates roi = self.cam.roi self.roiX1Lbl.setNum(roi[0]) self.roiY1Lbl.setNum(roi[1]) self.roiX2Lbl.setNum(roi[2]) self.roiY2Lbl.setNum(roi[3])
def hist(data): """Plots histogram""" win = CurveDialog(edit=False, toolbar=True, wintitle="Histogram test") plot = win.get_plot() plot.add_item(make.histogram(data)) win.show() win.exec_()
def test(): """Test""" from numpy.random import normal data = normal(0, 1, (2000, )) win = CurveDialog(edit=False, toolbar=True, wintitle="Histogram test") plot = win.get_plot() plot.add_item(make.histogram(data)) win.show() win.exec_()
def hist(data, bins=None, logscale=None, title=None, color=None): """ Plot 1-D histogram Example: from numpy.random import normal data = normal(0, 1, (2000, )) hist(data) show() """ axe = gca() curve = make.histogram(data, bins=bins, logscale=logscale, title=title, color=color, yaxis='left') axe.add_plot(curve) _show_if_interactive() return [curve]
def hist(data, bins=None, logscale=None, title=None, color=None): """ Plot 1-D histogram Example:: from numpy.random import normal data = normal(0, 1, (2000, )) hist(data) show() """ axe = gca() curve = make.histogram( data, bins=bins, logscale=logscale, title=title, color=color, yaxis="left" ) axe.add_plot(curve) _show_if_interactive() return [curve]
def __init__(self, fit): Plot.__init__(self, fit) self.layout = QtWidgets.QVBoxLayout(self) self.source = fit.surface self.d1 = np.array([0.0]) self.d2 = np.array([0.0]) top_left = QtWidgets.QFrame(self) top_left.setMaximumHeight(150) top_left.setFrameShape(QtWidgets.QFrame.StyledPanel) topl = QtWidgets.QVBoxLayout(top_left) top_right = QtWidgets.QFrame(self) top_right.setMaximumHeight(150) top_right.setFrameShape(QtWidgets.QFrame.StyledPanel) topr = QtWidgets.QVBoxLayout(top_right) bottom = QtWidgets.QFrame(self) bottom.setFrameShape(QtWidgets.QFrame.StyledPanel) bot = QtWidgets.QVBoxLayout(bottom) splitter1 = QtWidgets.QSplitter(QtCore.Qt.Horizontal) splitter1.addWidget(top_left) splitter1.addWidget(top_right) splitter2 = QtWidgets.QSplitter(QtCore.Qt.Vertical) splitter2.addWidget(splitter1) splitter2.addWidget(bottom) self.splitter = splitter2 self.layout.addWidget(splitter2) # x-axis win = CurveDialog() self.g_xplot = win.get_plot() self.g_xhist_m = make.histogram([], color='#ff00ff') self.g_xhist_a = make.histogram([], color='#6f0000') self.g_xplot.add_item(self.g_xhist_a) self.g_xplot.add_item(self.g_xhist_m) topl.addWidget(self.g_xplot) # y-axis win = CurveDialog() self.g_yplot = win.get_plot() self.g_yhist_m = make.histogram([], color='#00ff00') self.g_yhist_a = make.histogram([], color='#006600') self.g_yplot.add_item(self.g_yhist_a) self.g_yplot.add_item(self.g_yhist_m) topr.addWidget(self.g_yplot) # 2D-Histogram self.g_hist2d_m = make.histogram2D(np.array([0.0, 0.0]), np.array([0.0, 0.0]), logscale=True) self.g_hist2d_a = make.histogram2D(np.array([0.0, 0.0]), np.array([0.0, 0.0]), logscale=True) self.g_hist2d_m.set_color_map('hot') self.g_hist2d_a.set_color_map('Blues') #self.g_hist2d_m.set_interpolation(INTERP_LINEAR) #self.g_hist2d_a.set_interpolation(INTERP_LINEAR) win = ImageDialog(edit=False, toolbar=False) self.g_xyplot = win.get_plot() self.g_xyplot.set_aspect_ratio(lock=False) self.g_xyplot.add_item(self.g_hist2d_a) self.g_xyplot.add_item(self.g_hist2d_m) bot.addWidget(win) #selection self.selection_x = make.range(.25, .5) self.g_xplot.add_item(self.selection_x) self.selection_y = make.range(.25, .5) self.g_yplot.add_item(self.selection_y) self.pltControl = SurfacePlotWidget(self) self.widgets = [self.pltControl]