def __init__(self, parent=None, size = (7,3.5), dpi = 100, logx = False, logy = False, legends = True, bw = False): self.fig = Figure(figsize=size, dpi=dpi) #in inches FigureCanvas.__init__(self, self.fig) FigureCanvas.setSizePolicy(self, qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self.curveTable = None self.dpi=dpi ddict = {'logx':logx, 'logy': logy, 'legends':legends, 'bw':bw} self.ax=None self.curveList = [] self.curveDict = {} self.setParameters(ddict) #self.setBlackAndWhiteEnabled(bw) #self.setLogXEnabled(logx) #self.setLogYEnabled(logy) #self.setLegendsEnabled(legends) self.xmin = None self.xmax = None self.ymin = None self.ymax = None self.limitsSet = False
def __init__(self, xlim=None, ylim=None, channel=1, x_range=None, parent=None, post_process=None, width=5, height=4, dpi=100, *args, **kwargs): customthreads.StoppableThread.__init__(self, *args, **kwargs) self.lock = Lock() self.in_queue = queue.Queue() self.xlim = xlim self.ylim = ylim self.x_range = x_range if(self.x_range is None): self.x_range = range(self.xlim[0], self.xlim[1]) self.fig = Figure(figsize=(width, height), dpi=dpi) FigureCanvasQTAgg.__init__(self, self.fig) FigureCanvasQTAgg.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvasQTAgg.updateGeometry(self) self.axes_list = [] self.setParent(parent) self.set_channel(channel) self.post_process = post_process if(self.post_process is None): self.post_process = lambda data: data
def __init__(self): self.fig = Figure(facecolor="white", frameon=False) self.ax = self.fig.add_subplot(111) FigureCanvas.__init__(self, self.fig) FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self)
def __init__(self, parent=None, width=5, height=4, dpi=60): """ Descript. : """ self.mouse_position = [0, 0] self.max_plot_points = None self.fig = Figure(figsize=(width, height), dpi=dpi) self.axes = self.fig.add_subplot(111) FigureCanvas.__init__(self, self.fig) self.setParent(parent) FigureCanvas.setSizePolicy( self, QtImport.QSizePolicy.Expanding, QtImport.QSizePolicy.Expanding ) FigureCanvas.updateGeometry(self) self.single_curve = None self.real_time = None self._axis_x_array = np.empty(0) self._axis_y_array = np.empty(0) self._axis_x_limits = [None, None] self._axis_y_limits = [None, None] self._curves_dict = {} self.setMaximumSize(2000, 2000)
def __init__(self): self._draw_count = 0 interactive = matplotlib.is_interactive() matplotlib.interactive(False) self.roi_callback = None self._draw_zoom_rect = None self.fig = Figure(facecolor=settings.BACKGROUND_COLOR) FigureCanvas.__init__(self, self.fig) FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) self.manager = FigureManager(self, 0) matplotlib.interactive(interactive) self._resize_timer = QtCore.QTimer() self._resize_timer.setInterval(250) self._resize_timer.setSingleShot(True) self._resize_timer.timeout.connect(self._on_timeout) self.renderer = None
def __init__(self, subplot=111, parent=None, width=5, height=4, dpi=100, figfacecolor=3*[0.941], style=None, **kwargs): # super(MplCanvas, self).__init__(parent) if style is None: pass else: _mpl.style.use(style) # Create figure and axes self.fig = _Figure(figsize=(width, height), dpi=dpi, facecolor=figfacecolor, **kwargs) # Initialize the canvas FigureCanvas.__init__(self, self.fig) self.setParent(parent) self.setupAx(subplot=subplot, **kwargs) # Not really used, but could be used to have some sort of initial plot self.compute_initial_figure() # Set canvas size policies and geometry FigureCanvas.setSizePolicy(self, _QtWidgets.QSizePolicy.Expanding, _QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) # Create the toolbar and connect to canvas (self) self.toolbar = _NavigationToolbar(self, None)
def __init__(self): self.fig = Figure() self.ax = self.fig.add_subplot(111) FigureCanvas.__init__(self, self.fig) FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self)
def __init__(self, parent): self._driver = AddieDriver() # from mpl_toolkits.axes_grid1 import host_subplot # import mpl_toolkits.axisartist as AA # import matplotlib.pyplot as plt # Instantiating matplotlib Figure self.fig = Figure() self.fig.patch.set_facecolor('white') self.axes = self.fig.add_subplot(111, projection='mantid') self.fig.subplots_adjust(bottom=0.15) # Initialize parent class and set parent FigureCanvasQTAgg.__init__(self, self.fig) self.setParent(parent) # Set size policy to be able to expanding and resizable with frame FigureCanvasQTAgg.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvasQTAgg.updateGeometry(self) # Variables to manage all lines/subplot self._lineDict = {} self._lineIndex = 0 # legend and color bar self._colorBar = None self._isLegendOn = False self._legendFontSize = 10
def __init__(self): self.press = None self.cur_xlim = None self.cur_ylim = None self.x0 = None self.y0 = None self.x1 = None self.y1 = None self.xpress = None self.ypress = None self.zoom_x_limits = None self.zoom_y_limits = None self.fig = Figure() self.ax = self.fig.add_subplot(111, axisbg='white') FigureCanvas.__init__(self, self.fig) FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) scale = 1.2 f = self.zoom_factory(self.ax, base_scale=scale) # p = self.pan_factory(self.ax) self.dragged = None self.element_dragged = None self.pick_pos = (0, 0) self.is_point = False self.index = None
def __init__(self): self.fig = Figure() FigureCanvas.__init__(self, self.fig) FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self)
def __init__(self, parent=None, width=5, height=4, dpi=100): self.press = None self.prevX = 0 self.ydata = list() self.xdata = list() fig = Figure(figsize=(width, height), dpi=dpi) self.axes = fig.add_subplot(111) self.axes.hold(True) #self.compute_initial_figure() # FigureCanvas.__init__(self, fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) FigureCanvas.mpl_connect(self,'button_press_event', self.onclick) FigureCanvas.mpl_connect(self, 'button_release_event', self.onrelease) FigureCanvas.mpl_connect(self, 'motion_notify_event', self.onmove) FigureCanvas.mpl_connect(self, 'scroll_event', self.zoom) FigureCanvas.mpl_connect(self, 'pick_event', self.onpick) FigureCanvas.mpl_connect(self, 'figure_enter_event', self.on_enter) FigureCanvas.mpl_connect(self, 'figure_exit_event', self.on_exit)
def __init__(self): self.fig = Figure() FigureCanvas.__init__(self, self.fig) self.main_plot = None self.create_main_plot()
def __init__(self, parent, width=5, height=4, dpi=100, **kwargs): self.v = parent self.fig = Figure(figsize=(width, height), dpi=dpi) self.ax = self.fig.add_subplot(111) self.ax.plot([1, 2, 3, 4]) self.ax.spines['top'].set_visible(False) self.ax.spines['right'].set_visible(False) self.ax.get_xaxis().tick_bottom() self.ax.get_yaxis().tick_left() FigureCanvas.__init__(self, self.fig) self.setParent(parent.views) FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) # Install navigation handler; we need to provide a Qt interface that can handle multiple # plots in a window under separate tabs self.navigation = MplNavigationHandler(self) self._current_axis_bounds = None
def __init__(self): self._fig = Figure(dpi=170) FigureCanvasQTAgg.__init__(self, self._fig) FigureCanvasQTAgg.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self._fig.subplots_adjust(left=0, right=1, top=1, bottom=0) self._mpl_toolbar = NavigationToolbar2QTAgg(self, self) self._mpl_toolbar.hide() self.__taking = False self._scale = 'log' self._scales = OrderedDict() self._scales['Logarithmic'] = 'log' self._scales['Linear'] = 'linear' self._scales['Square Root'] = 'sqrt' self._scales['Power'] = 'power' self._scales['Arc Sinh'] = 'arcsinh' self._gc = None self._upperCut = 99.75 self._lowerCut = 0.25 self._cmap = 'gray' self._refresh_timer = QtCore.QTimer(self) self._refresh_timer.setSingleShot(True) self._refresh_timer.timeout.connect(self._refreshConcrete) self.apertures = []
def __init__(self, parent=None): self.fig = Figure() self.axes = self.fig.add_subplot(1, 1, 1) FigureCanvas.__init__(self, self.fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self)
def __init__(self, parent=None, width=6, height=4, dpi=110): """ Init canvas. """ self.fig = Figure(figsize=(width, height), dpi=dpi) # Here one can adjust the position of the CTX plot area. # self.axes = self.fig.add_subplot(111) self.axes = self.fig.add_axes([0.1, 0.1, 0.85, 0.85]) self.axes.grid(True) self.axes.set_xlabel("(no data)") self.axes.set_ylabel("(no data)") FigureCanvas.__init__(self, self.fig) layout = QVBoxLayout(parent) layout.addWidget(self) parent.setLayout(layout) FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) # next too lines are needed in order to catch keypress events in plot canvas by mpl_connect() FigureCanvas.setFocusPolicy(self, QtCore.Qt.ClickFocus) FigureCanvas.setFocus(self)
def __init__(self, parent=None, width=5, height=4, dpi=100): fig = Figure(figsize=(width, height), dpi=dpi) self.axes = fig.add_subplot(111) # We want the axes cleared every time plot() is called self.axes.hold(False) self.compute_initial_figure() # FigureCanvas.__init__(self, fig) self.setParent(parent) self.setStyleSheet("{background-color:transparent;border:none;}") """FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)""" FigureCanvas.updateGeometry(self) self.tootlbar = NavigationToolbar(self, parent) self.tootlbar.hide() self.fid = 0 self.data = [] self.index = []
def __init__(self, parent, latex_installed): self.myWidget = parent plot_background = myConfig.read("Plotting", "plot_background") plot_CanvasBackground = str(myConfig.read("Plotting", "plot_CanvasBackground")) plot_fontSize = int(myConfig.read("Plotting", "plot_fontSize")) plot_topOfPlot = float(myConfig.read("Plotting", "plot_topOfPlot")) plot_leftOfPlot = 0.12#float(myConfig.read("Plotting", "plot_leftOfPlot")) plot_rightOfPlot = float(myConfig.read("Plotting", "plot_rightOfPlot")) plot_bottomOfPlot = 0.1#float(myConfig.read("Plotting", "plot_bottomOfPlot")) self.fig = pl.Figure(facecolor=plot_background) pl.matplotlib.rc('font', size=plot_fontSize) # Check if LaTeX and dvipng are installed on this system since this # is required by matplotlib for fine rendering. If it is not installed # only basic rendering will be done in the following rc('text', usetex=latex_installed) # ALIASING # TODO: read aliasing variables: # pl.matplotlib.rc('lines', antialiased=False) # pl.matplotlib.rc('text', antialiased=False) # pl.matplotlib.rc('patch', antialiased=False) self.axes = self.fig.add_subplot(111) # Matplotlib 2.0 vs. 1.5 behavior... try: self.axes.set_facecolor(plot_CanvasBackground) # Matplotlib >= 2 except AttributeError: self.axes.set_axis_bgcolor(plot_CanvasBackground) # Matplotlib < 2 # matplotlib background transparent (issues on old versions?) if myConfig.get_boolean("Plotting", "plot_backgroundTransparent"): self.fig.frameon = False self.adjust = self.fig.subplots_adjust(top=plot_topOfPlot, left=plot_leftOfPlot, right=plot_rightOfPlot, bottom=plot_bottomOfPlot) FigureCanvas.__init__(self, self.fig) self.setParent(parent) self.navigationToolbar = Toolbar(self) # TODO: rather as a real toolbar: # self.toolbar = NavigationToolbar(self, self.myWidget.mpl_layout, coordinates=True) # self.myWidget.mplvl.addWidget(self.toolbar) FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) # zoom mode on/off self.zoomMode = False myLogger.debug_message(str(self) + ": initialized")
def __init__(self, parent=None, width=15, height=5, dpi=100): self.fig = Figure(figsize=(width, height), dpi=dpi) FigureCanvasQTAgg.__init__(self, self.fig) self.setParent(parent) self.ax = self.fig.add_subplot(111) # self.ax.figure.subplots_adjust(left=0.08, right=0.92, bottom=0.1, top=0.95) FigureCanvasQTAgg.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvasQTAgg.updateGeometry(self)
def __init__(self, parent, width, height, dpi=100): self.fig = Figure(figsize=(width, height), dpi=dpi) self.ax = self.fig.add_subplot(111) self.ax.hold(False) self.ax.xaxis.set_visible(False) self.ax.yaxis.set_visible(False) FigCanvas.__init__(self, self.fig) self.setParent(parent)
def __init__(self, parent=None, width=5, height=4, dpi=100): self.fig = Figure(figsize=(width, height), dpi=dpi) self.axis = self.fig.add_subplot(111) FigureCanvas.__init__(self, self.fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, QSizePolicy.Fixed, QSizePolicy.Fixed) FigureCanvas.updateGeometry(self) self.createInitialFigure()
def __init__(self, parent=None, width=5, height=4, dpi=100): self.fig = Figure(figsize=(width, height), dpi=dpi) self.axes = self.fig.add_subplot(111) # We want the axes cleared every time plot() is called # self.axes.hold(False) FigureCanvas.__init__(self, self.fig) self.setParent(parent) FigureCanvas.setSizePolicy(self,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self)
def __init__(self, parent=None): self.fig = Figure(dpi=40) self.axes = self.fig.add_subplot(111) self.axes.hold(False) self.fig.set_facecolor('white') FigureCanvas.__init__(self, self.fig) self.setParent(parent) self.axes.get_yaxis().set_visible(False) self.fig.tight_layout(pad=1, h_pad=1)
def __init__(self, parent=None, width=7, height=2, dpi=100): fig = Figure(figsize=(width, height), dpi=dpi) self.axes = fig.add_subplot(111) self.axes.hold(False) self.compute_initial_figure() FigureCanvas.__init__(self, fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self)
def __init__(self, nAxes): self.fig = Figure(facecolor="white", frameon=False) self.axes=[] for i in range(nAxes): self.axes.append(self.fig.add_subplot(2, numpy.ceil(nAxes/2.),i+1)) FigureCanvas.__init__(self, self.fig) FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self)
def __init__(self, parent=None, width=5.0, height=4.0, dpi=100): fig = Figure((width, height), dpi=dpi) self.axes = fig.add_subplot(1, 1, 1) FigureCanvas.__init__(self, fig) self.setParent(parent) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.updateGeometry() self.plot()
def __init__(self, parent, model, width=5, height=5, dpi=100): self.fig = Figure(figsize=(width, height), dpi=dpi, facecolor="0.95") self.model = model FigureCanvas.__init__(self, self.fig) FigureCanvas.setSizePolicy(self, QW.QSizePolicy.Expanding, QW.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) self.redraw() self.setParent(parent)
def __init__(self, parent = None, width = 5, height = 4, dpi = 1000): fig = Figure(figsize = (width, height), dpi = dpi) self.axes = fig.add_subplot(111) FigureCanvas.__init__(self, fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) self.plot()
def __init__(self, width=5, height=4, dpi=100): self.fig = Figure(figsize=(width, height), dpi=dpi) FigureCanvas.__init__(self, self.fig) FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) self.axes = []
def __init__(self): # Figure self.figure = Figure() # Add subplot for plot and legend self.ax = self.figure.add_axes([0.1, 0.15, 0.8, 0.8]) # Canvas initialization FigCanvas.__init__(self, self.figure) # Set empty ticks self.ax.set_xticks([]) self.ax.set_yticks([])
def __init__(self, parent=None, width=15, height=15): plt.rcParams['font.family'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False self.fig = plt.figure(figsize=(width, height)) #self.openfile_name='' self.model = {} self.w_count = 0 self.f_count = 0 self.s_count = 0 self.layerWeights = {} # {layer name: weights value} self.edgesInLayerName = [] #(input layer name, output layer name) self.allLayerNames = [] self.axesDict = {} self.activations = {} self.weights = {} self.subset_selection = {} self.chosenLayerName = [] self.ind = 0 self.nrows = 0 self.ncols = 0 self.totalPatches = 0 # subset selection parameters self.totalSS = 0 self.chosenSSNumber = 0 FigureCanvas.__init__(self, self.fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self)
def __init__(self, parent=None, width=4, height=3, dpi=100, img=None, img_type=None, log=False, mask=False, vmax=None, vmin=None, dexp=None): #super().__init__() self.fig = Figure(figsize=(width, height), dpi=dpi) self.log = log self.mask_check = mask self.vmax = vmax self.vmin = vmin self.dexp = dexp FigureCanvas.__init__(self, self.fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) #self.toolbar = NavigationToolbar(FigureCanvas(self.fig),self) self.axes = self.fig.add_subplot(111) self.img = img if img_type == 'SAXS': self.exp = self.dexp.detectors[0].exp_para self.mask = self.dexp.detectors[0].exp_para.mask elif img_type == 'WAXS1': self.exp = self.dexp.detectors[1].exp_para self.mask = self.dexp.detectors[1].exp_para.mask elif img_type == 'WAXS2': self.exp = self.dexp.detectors[2].exp_para self.mask = self.dexp.detectors[2].exp_para.mask self.plot()
def __init__(self, parent=None, num_elems=10): self.fig = plt.figure(figsize=(8, 3), dpi=80, facecolor='white') self.ax1 = self.fig.add_subplot(121) # We want the axes cleared every time plot() is called self.ax1.hold(False) FigureCanvas.__init__(self, self.fig) self.setParent(parent) self.nelem = num_elems # store M, K, freq, evecs self.result = [] for self.counter in range(1, self.nelem + 1): M, K, freq, evecs = self.compute() exact_freq = math.pi / 2 error = (freq[0] - exact_freq) / exact_freq * 100 self.result.append((self.counter, error, freq[0])) self.elements = np.array([x[0] for x in self.result]) self.err = np.array([x[1] for x in self.result]) self.freq = np.array([x[2] for x in self.result]) # convert result(element no, error, frequency) to an array self.storearr = np.array(self.result) # plot elements vs error self.ax1.plot(self.elements, self.err, linestyle='--', color='blue') plt.xlabel('number of elements') plt.ylabel('error (%)') # fit plot size to figure frame plt.tight_layout() self.ax2 = self.fig.add_subplot(122) self.ax2.plot(self.elements, self.freq, color='red') plt.xlabel('number elements') plt.ylabel('frequency (Hz)') plt.tight_layout()
def __init__(self, parent=None, title='', xlabel='', ylabel='', xlim=None, ylim=None, xscale='linear', yscale='linear', width=4, height=3, dpi=100): self.figure = Figure(figsize=(width, height), dpi=dpi) self.axes = self.figure.add_subplot(111) self.axes.set_title(title) self.axes.set_xlabel(xlabel) self.axes.set_ylabel(ylabel) if xscale is not None: self.axes.set_xscale(xscale) if yscale is not None: self.axes.set_yscale(yscale) if xlim is not None: self.axes.set_xlim(*xlim) if ylim is not None: self.axes.set_ylim(*ylim) Canvas.__init__(self, self.figure) self.setParent(parent) Canvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) Canvas.updateGeometry(self)
def __init__(self, width=11.7, height=8.3, dpi=100, parent=None): self._figure = LayoutFigure(width, height, dpi) FigureCanvas.__init__(self, self._figure) self.setParent(parent) self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.updateGeometry() self.setFocusPolicy(Qt.WheelFocus) self.setFocus() self.mpl_connect('scroll_event', self._mouse_scrolled) self.mpl_connect('button_press_event', self._mouse_pressed) self.mpl_connect('button_release_event', self._mouse_released) self.mpl_connect('motion_notify_event', self._mouse_motion) self.mpl_connect('key_press_event', self._key_press_event) self.mpl_connect('key_release_event', self._key_release_event) self._start_x = None self._start_y = None self._start_subplot_index = None self._keys = Keys()
def __init__(self, parent, opts={}): self.opts = opts fig = Figure(figsize=(9, 4), dpi=50) FigureCanvas.__init__(self, fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, \ QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) ax = self.figure.add_subplot(111) # self.figure.title = '123' ax.set_title(opts['title']['value']) for f in opts['func']: xs, ys = f['xy']['value'] ax.plot(xs, ys, 'ro') for h in opts['hist']: # int(bins * ((vmax - vmin) / (fmax - fmin))), (vmin, vmax)) # -300, 300, 1000 ax.hist(list(h['data']['value']), 1000, (-300, 300)) self.figure.tight_layout() self.draw()
def __init__(self, parent=None, width=5, height=4, dpi=100): # 配置中文显示 plt.rcParams['font.family'] = ['SimHei'] # 用来正常显示中文标签 plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号 self.fig = Figure(figsize=(width, height), dpi=dpi) # 新建一个figure self.axes = self.fig.add_subplot(111) # 建立一个子图,如果要建立复合图,可以在这里修改 self.fig.subplots_adjust(left=0.180, bottom=0.110, right=0.990, top=0.990, wspace=None, hspace=None) #self.axes.hold(False) # 每次绘图的时候不保留上一次绘图的结果 FigureCanvas.__init__(self, self.fig) self.setParent(parent) '''定义FigureCanvas的尺寸策略,这部分的意思是设置FigureCanvas,使之尽可能的向外填充空间。''' FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self)
def __init__(self, data_path, num, noise_file, parent=None, width=5, height=4, dpi=100): fig = Figure(figsize=(width, height), dpi=dpi) self.axes = fig.add_subplot(111) self.load_wav(data_path) self.compute_initial_figure() self.noise_file = noise_file[0] self.num = num FigureCanvas.__init__(self, fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self)
def __init__(self, parent=None, width=4, height=2, dpi=100): self.fig = myFigure(self, width, height, dpi) FigureCanvas.__init__(self, self.fig) self.setParent(parent.parent) FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) self.parent = parent self.dataset = self.parent.parent.dataset self.numDate = self.parent.parent.getNumdate() self.rdy_check = False self.onDrawing = False self.dictofline = {} self.ax = self.fig.add_subplot(111) self.ax.xaxis_date() self.ax.set_autoscale_on(True) self.ax2 = self.ax.twinx() self.ax2.format_coord = self.make_format(self.ax2, self.ax) self.label_cursor = QLabel(self) self.label_cursor.setWordWrap(True) self.label_cursor.hide()
def __init__(self, fig): """ TODO: Add Summary Args: fig: """ self.fig = fig FigureCanvas.__init__(self, self.fig) if len(fig.axes) >= 3: sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Minimum) else: sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) FigureCanvas.setSizePolicy(self, sizePolicy) FigureCanvas.updateGeometry(self)
def __init__(self): # self.x = x self.fig = Figure() self.fig.set_tight_layout(True) self.ax1 = self.fig.add_subplot(211) self.ax1.set_title("Whole Chr (Mb)") self.ax2 = self.fig.add_subplot(212) self.ax2.set_title("Zoom in Region (Kb)") self.line2 = object() FigureCanvas.__init__(self, self.fig) FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self)
def __init__(self, parent=None, width=5, height=4, dpi=100, animation_speed=1): self.fig = Figure(figsize=(width, height), dpi=dpi) self.axes = self.fig.add_subplot(111) self.axes.set_axis_off() self.axes.autoscale_view() self.draw_done = True self.max_frame = 0 self.animation_speed = animation_speed self.list_point = [] self.list_annotation = [] self.scatter = self.axes.scatter([],[]) self.animation_animation = None FigureCanvas.__init__(self, self.fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self)
def __init__(self, dim=2, parent=None): self.fig = Figure(figsize=(10, 10), dpi=100) self.dim = dim FigureCanvasQTAgg.__init__(self, self.fig) self.setParent(parent) FigureCanvasQTAgg.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvasQTAgg.updateGeometry(self) if dim == 2: self.ax = self.fig.add_subplot(111) self.ax.figure.subplots_adjust(left=0.08, right=0.98, bottom=0.08, top=0.92) else: self.ax = Axes3D(self.fig) self.ax.mouse_init(rotate_btn=1, zoom_btn=2) FigureCanvasQTAgg.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvasQTAgg.updateGeometry(self)
def __init__(self, parent=None, moon_az=0.1, moon_alt=0.1, moon_appdia=0.1, sun_az=0.2, sun_alt=0.1, sun_appdia=0.1, width=5, height=4, dpi=100): fig = Figure(figsize=(width, height), dpi=dpi) self.moon_az = moon_az self.moon_alt = moon_alt self.moon_appDia = moon_appdia self.sun_alt = sun_alt self.sun_az = sun_az self.sun_appDia = sun_appdia FigureCanvasQTAgg.__init__(self, fig) self.setParent(parent) self.plot()
def __init__(self): self._draw_count = 0 interactive = matplotlib.is_interactive() matplotlib.interactive(False) self.roi_callback = None self.fig = Figure(facecolor=settings.BACKGROUND_COLOR) FigureCanvas.__init__(self, self.fig) FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) self.manager = FigureManager(self, 0) matplotlib.interactive(interactive) self._resize_timer = QtCore.QTimer() self._resize_timer.setInterval(250) self._resize_timer.setSingleShot(True) self._resize_timer.timeout.connect(self._on_timeout) self.renderer = None
def __init__(self): """ Constructor """ # Crea una figura de matplotlib self.fig = Figure(facecolor='0.94') # Agrega unos ejes self.ax = self.fig.add_axes([0.1, 0.1, 0.8, 0.8]) self.ax.set_xticks(np.arange(8)) self.ax.set_xticklabels(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']) self.ax.set_yticks(np.arange(8)) self.ax.set_yticklabels(['1', '2', '3', '4', '5', '6', '7', '8']) self.fondo = np.array([[0., 1., 0., 1., 0., 1., 0., 1.], [1., 0., 1., 0., 1., 0., 1., 0.], [0., 1., 0., 1., 0., 1., 0., 1.], [1., 0., 1., 0., 1., 0., 1., 0.], [0., 1., 0., 1., 0., 1., 0., 1.], [1., 0., 1., 0., 1., 0., 1., 0.], [0., 1., 0., 1., 0., 1., 0., 1.], [1., 0., 1., 0., 1., 0., 1., 0.]]) self.ax.imshow(self.fondo, cmap='binary', alpha=0.5) # invoca al constructor de la clase FigureCanvasQTAgg.__init__(self, self.fig)
def __init__(self, parent=None, style='fast'): with plt.style.context(style): fig = Figure(figsize=(40, 40), dpi=80) super(__class__, self).__init__(fig) self._style = style self.delayEnabled = False self.delayTimeout = 100 self._resizeTimer = QtCore.QTimer(self) self._resizeTimer.timeout.connect(self._delayed_update) self.axes = self.figure.add_subplot(111) self.figure.set_tight_layout(True) self.axes.set_aspect('equal') FigureCanvasQTAgg.__init__(self, self.figure) self.setParent(parent) FigureCanvasQTAgg.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvasQTAgg.updateGeometry(self)
def __init__(self, DatabaseValues, sessionId, plotChannels, timeIntervall): self.databaseValues = DatabaseValues self.sessionId = sessionId self.plotChannels = plotChannels self.timeInterval = timeIntervall #figureTitle = "Kanal: %s" % figureTitle self.plotChannelValues = {} self.figure = Figure(figsize=(10, 10), dpi=100) #self.figure.suptitle(figureTitle) self.axes = self.figure.add_subplot(111) self.axes.xaxis_date() # self.axes.hold(False) FC.__init__(self, self.figure) FC.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FC.updateGeometry(self) self.timer = QtCore.QTimer() self.timer.timeout.connect(self.updateFigure) self.mpl_connect('button_press_event', self.onClick)
def __init__(self, parent=None, width=8, height=3, dpi=80): self.fig = Figure(figsize=(width, height), dpi=dpi) self.axes = self.fig.add_subplot(111) FigureCanvas.__init__(self, self.fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) self.values = [0] self.times = [datetime.datetime.now().strftime('%S')] self.bgColor = '#373435' self.lineColor = '#92d500' self.gridColor = '#575757' matplotlib.rc('lines', linewidth=3, color=self.lineColor) matplotlib.rc('axes', facecolor=self.bgColor, edgecolor=self.gridColor, grid=True) matplotlib.rc('figure', facecolor=self.bgColor) matplotlib.rc('xtick', top=False, bottom=False, color=self.gridColor) matplotlib.rc('xtick.major', width=25) matplotlib.rc('xtick.minor', width=20) matplotlib.rc('ytick', left=False, right=False, color=self.gridColor)
def __init__(self, parent=None, width=5, height=4, dpi=100): self.fig = Figure(figsize=(width, height), dpi=dpi) self.axes = self.fig.add_subplot(111) FigureCanvas.__init__(self, self.fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) self.mpl_connect("motion_notify_event", self.hover) self.label = QApplication.translate('BaseCanvas', "Number of coins") self.colors = None self.multicolors = ('#336699', '#99CCFF', '#999933', '#666699', '#CC9933', '#006666', '#3399FF', '#993300', '#CCCC99', '#666666', '#FFCC66', '#6699CC', '#663366', '#9999CC', '#CCCCCC', '#669999', '#CCCC66', '#CC6600', '#9999FF', '#0066CC', '#99CCCC', '#999999', '#FFCC00', '#009999', '#99CC33', '#FF9900', '#999966', '#66CCCC', '#339966', '#CCCC33')
def __init__(self, parent, width=5, height=4, dpi=100): self.parent = parent self.xticks = [''] if isCompositeTest(self.parent.info[1]): for i in range(len(CompositeList[self.parent.info[1]])): self.xticks.append(Test[CompositeList[self.parent.info[1]][i]]) if isSingleTest(self.parent.info[1]): self.xticks.append(Test[self.parent.info[1]]) self.grades = self.parent.grades self.fig = Figure(figsize=(width, height), dpi=dpi) self.axes = self.fig.add_subplot(111) self.compute_initial_figure() FigureCanvas.__init__(self, self.fig) self.setParent(self.parent) self.setMinimumHeight(1) FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self)
def __init__(self, parent=None, width=5, height=4, dpi=1200): self.fig = Figure(figsize=(width, height), dpi=dpi, tight_layout=True) self.axes = self.fig.add_subplot(111) self.condition_axes = self.axes.twinx() self.condition_axes.set_axis_off() self.axes.set_zorder(self.condition_axes.get_zorder() + 1) self.axes.patch.set_visible(False) self.dragged = None FigureCanvasQTAgg.__init__(self, self.fig) self.setParent(parent) self.parent = parent self.legend_on = False self.condition_legend_on = False self.plot_config = [] FigureCanvasQTAgg.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvasQTAgg.updateGeometry(self) self.plot()
def __init__(self, dirDicom='', parent=None, width=5, height=5, dpi=100): # Initialize the figure that will be housed by the canvas fig = matplotlib.figure.Figure(figsize=(width, height), dpi=dpi) self.axes = fig.add_axes([0, 0.05, 1, 1]) # Disable the axis ticks self.axes.get_xaxis().set_ticks([]) self.axes.get_yaxis().set_ticks([]) # Initialize the canvas FigureCanvas.__init__(self, fig) self.setParent(parent) FigureCanvas.setSizePolicy(self, PyQt5.QtWidgets.QSizePolicy.Expanding, PyQt5.QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) # Initialize the image index self.idxFiles = 0 # Show the image self.imshow()
def __init__(self, parent=None): X = parent.X Y = parent.Y Z = parent.Z fig = Figure() self.ax = fig.add_subplot(1, 1, 1, projection='3d') FigureCanvas.__init__(self, fig) #self.setParent(parent) FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) for i in range(parent.displayedDisks): self.ax.plot_surface(X[i], Y[i], Z[i], alpha=0.3, color='red', rstride=6, cstride=12)
def __init__(self, paramf, parent=None, width=5, height=4, dpi=40, title='Simulation Viewer'): FigureCanvas.__init__(self, Figure(figsize=(width, height), dpi=dpi)) self.title = title self.lextdatobj = [] # external data object self.clridx = 5 # index for next color for drawing external data self.lpatch = [mpatches.Patch(color='black', label='Sim.') ] # legend for dipole signals self.setParent(parent) self.gui = parent FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) self.paramf = paramf self.invertedhistax = False self.initaxes() self.G = gridspec.GridSpec(10, 1) self.plot()
def __init__(self, parent=None, width=6, height=4, dpi=110): """ Init canvas. """ self.fig = Figure(figsize=(width, height), dpi=dpi) # Here one can adjust the position of the CTX plot area. self.axes = self.fig.add_axes([0.1, 0, 1, 1]) # self.axes = self.fig.add_subplot(111) FigureCanvas.__init__(self, self.fig) layout = QVBoxLayout(parent) layout.addWidget(self) parent.setLayout(layout) FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) # next too lines are needed in order to catch keypress events in plot canvas by mpl_connect() FigureCanvas.setFocusPolicy(self, QtCore.Qt.ClickFocus) FigureCanvas.setFocus(self)
def __init__(self, parent=None, ancho=10, alto=10, dpi=100): # las imagenes médicas en formato DICOM self.Figura_1 = Figure(figsize=(ancho, alto), dpi=dpi) self.Figura_1.set_facecolor('#cfebfb') # #052b2e #dffdfd <- #99f7f7 gs = gridspec.GridSpec( 1, 3, width_ratios=[50, 50, 50], height_ratios=[50]) # Se crea un gridspec para mejor el self.plano_axial = self.Figura_1.add_subplot( gs[0]) # tamaño de las imagenes graficadas self.plano_coronal = self.Figura_1.add_subplot(gs[1]) self.plano_sagital = self.Figura_1.add_subplot(gs[2]) self.plano_axial.set_title("Plano Transversal") self.plano_coronal.set_title("Plano Frontal") self.plano_sagital.set_title("Plano Sagital") self.contador_imagen_guardada = 0 #self.Figura_1.set_tight_layout(True) FigureCanvas.__init__(self, self.Figura_1)
def __init__(self, parent=None, width=5, height=3, dpi=100, xlabel='', ylabel='', ymin=0, ymax=0, auto_ylim=True, Xarray=[], Yarray=[]): fig = Figure(figsize=(width, height), dpi=dpi) axes = fig.add_subplot(111) FigureCanvas.__init__(self, fig) # FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) # FigureCanvas.updateGeometry(self) fig.patch.set_alpha(0) rcParams.update({"font.size": 8}) axes.grid(color='gray', linestyle=':') axes.set_ylabel(ylabel) axes.set_xlabel(xlabel) axes.xaxis.set_label_position('top') axes.yaxis.set_label_position('right') if not auto_ylim: axes.set_ylim([ymin, ymax]) axes.plot(Xarray, Yarray) self.canvas = FigureCanvas(fig) self.graphToolbar = NavigationToolbar(self.canvas, self)
def __init__(self, subplot=111, parent=None, width=5, height=4, dpi=100, figfacecolor=3 * [0.941], style=None, **kwargs): # super(MplCanvas, self).__init__(parent) if style is None: pass else: _mpl.style.use(style) # Create figure and axes self.fig = _Figure(figsize=(width, height), dpi=dpi, facecolor=figfacecolor, **kwargs) # Initialize the canvas FigureCanvas.__init__(self, self.fig) self.setParent(parent) self.setupAx(subplot=subplot, **kwargs) # Not really used, but could be used to have some sort of initial plot self.compute_initial_figure() # Set canvas size policies and geometry FigureCanvas.setSizePolicy(self, _QtWidgets.QSizePolicy.Expanding, _QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) # Create the toolbar and connect to canvas (self) self.toolbar = _NavigationToolbar(self, None)
def __init__(self, parent=None, width=1, height=1, dpi=100): #Plot config self.fig = plt.figure() FigureCanvas.__init__(self, self.fig) self.axes = self.fig.add_subplot(111) #hide x's and y's labels self.axes.set_yticklabels([]) self.axes.set_xticklabels([]) #Grid configuration self.axes.grid(b=True, which='major', color='k', linestyle='-') self.axes.minorticks_on() self.axes.grid(b=True, which='minor', linestyle='--') self.canvas = FigureCanvas(self.fig) self.canvas.setParent( parent) #really important to do this for the gui to show image self.canvas.move(60, 80) #these are empty arrays for channel data self.channelA1 = [] self.channelA2 = [] self.channelD1 = [] self.channelD2 = [] self.timescale = np.linspace(start=0, stop=1, num=2000, endpoint=True) self.xticks = np.linspace( 0, 1, 10) #these both are based on project requirements self.yticks = np.linspace(0, 3, 10) self.axes.xaxis.set_ticks(self.xticks) self.axes.yaxis.set_ticks(self.yticks) #open serial port for serial communication with DEM0QE self.dataSerial = openPort(listPorts(sys.platform))