def create_main_panel(self): self.panel = wx.Panel(self) self.init_plot() self.canvas = FigCanvas(self.panel, -1, self.fig) self.toolbar = NavigationToolbar(self.canvas) # self.toolbar.Show() self.create_ctrls() self.Bind(wx.EVT_BUTTON, self.on_pause_button, self.pause_button) self.Bind(wx.EVT_UPDATE_UI, self.on_update_pause_button, self.pause_button) self.h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.h_sizer.Add(self.pause_button, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.h_sizer.AddSpacer(20) self.h_sizer.Add(self.valdate_lb, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.h_sizer.Add(self.valdate_txt_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.h_sizer.AddSpacer(20) self.h_sizer.Add(self.r_lb, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.h_sizer.Add(self.r_txt_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.h_sizer.AddSpacer(20) self.h_sizer.Add(self.q_lb, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.h_sizer.Add(self.q_txt_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.v_sizer = wx.BoxSizer(wx.VERTICAL) self.v_sizer.Add(self.canvas, 2, flag=wx.LEFT | wx.TOP | wx.GROW) self.v_sizer.Add(self.toolbar, 0, wx.EXPAND) self.v_sizer.Add(self.h_sizer, 0, wx.EXPAND) self.panel.SetSizerAndFit(self.v_sizer)
def __init__(self, parent): wx.Panel.__init__(self, parent, wx.ID_ANY) self.parent = parent self.plot_panel = wx.Panel(self, wx.ID_ANY, style=wx.SIMPLE_BORDER) # PLOT Panel --------------------------------------------------------------------------------------------------- self.figure = plt.figure(figsize=(1, 1)) # look into Figure((5, 4), 75) self.canvas = FigureCanvas(self.plot_panel, -1, self.figure) self.toolbar = NavigationToolbar(self.canvas) self.toolbar.Realize() self.ax1 = self.figure.add_subplot(211) self.ax2 = self.figure.add_subplot(212) self.temporal, = self.ax1.plot([], [], linestyle='-') self.spectral, = self.ax2.plot([], [], color='#C02942') # Open history dialog ------------------------------------------------------------------------------------------ self.btn_openHistory = wx.Button(self, wx.ID_ANY, "Open History") self.Bind(wx.EVT_BUTTON, self.OnOpen, self.btn_openHistory) self.text_ctrl_fs = wx.TextCtrl(self, wx.ID_ANY, "") self.text_ctrl_samples = wx.TextCtrl(self, wx.ID_ANY, "") self.text_ctrl_rms = wx.TextCtrl(self, wx.ID_ANY, "") self.text_ctrl_thdn = wx.TextCtrl(self, wx.ID_ANY, "") self.text_ctrl_thd = wx.TextCtrl(self, wx.ID_ANY, "") self.__set_properties() self.__do_layout() self.__do_plot_layout()
def __init__(self, parent, id=-1, dpi=None, **kwargs): wx.Panel.__init__(self, parent, id=id, **kwargs) self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2)) self.canvas = FigureCanvas(self, -1, self.figure) self.toolbar = NavigationToolbar(self.canvas) self.toolbar.Realize() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, wx.EXPAND) btn = wx.Button(self, -1, "Toggle curve") sizer.Add(btn, 0, wx.EXPAND) screenSize = wx.DisplaySize() screenWidth, screenHeight = screenSize text_panel = wx.lib.scrolledpanel.ScrolledPanel(self, -1, size=(screenWidth, 100), style=wx.SIMPLE_BORDER) text_panel.SetupScrolling() text_sizer = wx.BoxSizer(wx.VERTICAL) text_panel.SetSizer(text_sizer) def when_clicked(ev): print(ev) text_sizer.Add(wx.StaticText(text_panel, label="coucou"), 0) self.Layout() btn.Bind(wx.EVT_BUTTON, when_clicked) sizer.Add(text_panel, 1, wx.LEFT | wx.EXPAND) sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) self.SetSizer(sizer)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.figure = plt.figure() self.canvas = FigureCanvas(self, -1, self.figure) self.toolbar = NavigationToolbar(self.canvas) self.toolbar.Hide()
def __init__(self): wx.Frame.__init__(self, None, -1) self.panel = wx.Panel(self) self.fig = plt.figure() self.canvas = FigCanvas(self.panel, -1, self.fig) G = nx.house_graph() pos = {0: (0, 0), 1: (1, 0), 2: (0, 1), 3: (1, 1), 4: (0.5, 2.0)} nx.draw_networkx_nodes(G, pos, node_size=2000, nodelist=[4]) nx.draw_networkx_nodes(G, pos, node_size=3000, nodelist=[0, 1, 2, 3], node_color='b') nx.draw_networkx_edges(G, pos, alpha=0.5, width=6) plt.axis('off') self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.toolbar = NavigationToolbar(self.canvas) self.vbox.Add(self.toolbar, 0, wx.EXPAND) self.panel.SetSizer(self.vbox) self.vbox.Fit(self) # plt.savefig("house_with_colors.png") # save as png
def __init__(self,panel,yourself): self.dpi = 80 self.fig = Figure((3.0, 2.0), dpi=self.dpi) self.canvas = FigCanvas(panel, -1, self.fig) self.gs = gridspec.GridSpec(1,1) self.axes = [None] #self.fig.canvas.mpl_connect('pick_event',self.on_pick) self.toolbar = NavigationToolbar(self.canvas) self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.vbox.Add(self.toolbar, 0, wx.EXPAND) self.vbox.AddSpacer(10) panel.SetSizer(self.vbox) self.canvas.draw() self.pickedValue = None self.pickingActive = False self.pickedAlready = False self.tempAnnotation = None self.settings = IesSettings.IesSettings('') self.currentPlot = IesPlotState.MASS_SPECTRA self.lift = 30 self.picker = None self.pickedValue = None self.gui = yourself
def drawplot(self, img, img_name, itr, index, bodyparts, cmap, keep_view=False): xlim = self.axes.get_xlim() ylim = self.axes.get_ylim() self.axes.clear() # convert the image to RGB as you are showing the image with matplotlib im = cv2.imread(img)[..., ::-1] colorIndex = np.linspace(np.max(im), np.min(im), len(bodyparts)) # draw epipolar lines epLines, sourcePts, offsets = self.retrieveData_and_computeEpLines(img, itr) if epLines is not None: im = self.drawEpLines(im.copy(), epLines, sourcePts, offsets, colorIndex, cmap) ax = self.axes.imshow(im, cmap=cmap) self.orig_xlim = self.axes.get_xlim() self.orig_ylim = self.axes.get_ylim() divider = make_axes_locatable(self.axes) cax = divider.append_axes("right", size="5%", pad=0.05) cbar = self.figure.colorbar( ax, cax=cax, spacing="proportional", ticks=colorIndex ) cbar.set_ticklabels(bodyparts) self.axes.set_title(str(str(itr) + "/" + str(len(index) - 1) + " " + img_name)) if keep_view: self.axes.set_xlim(xlim) self.axes.set_ylim(ylim) if self.toolbar is None: self.toolbar = NavigationToolbar(self.canvas) return (self.figure, self.axes, self.canvas, self.toolbar)
def __init__(self, data, title="a title"): """ Create a new Matplotlib plotting window for a 1D line plot """ print self.__class__.__name__ BaseFrame.__init__(self, id=wx.ID_ANY, title=title, size=(800, 400)) self.data = data self.panel = wx.Panel(self) self.dpi = 100 self.fig = Figure((6.0, 4.0), dpi=self.dpi) self.canvas = FigCanvas(self.panel, -1, self.fig) self.axes = self.fig.add_subplot(111) self.toolbar = NavigationToolbar(self.canvas) self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.vbox.Add(self.toolbar, 0, wx.EXPAND) self.panel.SetSizer(self.vbox) self.vbox.Fit(self) self.draw_figure()
def __init__(self,parent): wx.Panel.__init__(self, parent) self.figure = Figure() self.canv = FigCanvas(self,-1, self.figure) self.toolbar = NavigationToolbar(self.canv) self.toolbar.Hide() self.home = wx.lib.buttons.GenBitmapButton(self, -1, wx.Bitmap('icons/home.jpg')) self.Bind(wx.EVT_BUTTON, self.Home, self.home) self.pan = wx.lib.buttons.GenBitmapButton(self, -1, wx.Bitmap('icons/pan.png')) self.Bind(wx.EVT_BUTTON, self.Pan, self.pan) self.zoom = wx.lib.buttons.GenBitmapButton(self, -1, wx.Bitmap('icons/zoom.jpg')) self.Bind(wx.EVT_BUTTON, self.Zoom, self.zoom) self.plot = wx.lib.buttons.GenBitmapButton(self, -1, wx.Bitmap('icons/plot.png')) self.Bind(wx.EVT_BUTTON, self.Plot_a, self.plot) self.process = wx.lib.buttons.GenBitmapButton(self, -1, wx.Bitmap('icons/processing.png')) self.Bind(wx.EVT_BUTTON, self.Processing, self.process) self.hbox1 = wx.BoxSizer(wx.HORIZONTAL) self.hbox1.Add(self.home, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.hbox1.Add(self.pan, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.hbox1.Add(self.zoom, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.hbox1.Add(self.plot, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.hbox1.Add(self.process, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canv, 1, flag=wx.LEFT | wx.TOP | wx.GROW) self.vbox.Add(self.hbox1, 0, flag=wx.ALIGN_CENTER | wx.TOP) self.SetSizer(self.vbox)
def createPlot(self): self.fgm_data = [] self.year = date[0:4] self.month = date[5:7] self.day = date[8:10] self.hour_start = t_start[0:2] self.minute_start = t_start[3:5] self.second_start = t_start[6:8] self.hour_stop = t_stop[0:2] self.minute_stop = t_stop[3:5] self.second_stop = t_stop[6:8] self.date_time = datetime.datetime(int(self.year), int(self.month), int(self.day), int(self.hour_start), int(self.minute_start), int(self.second_start)) self.doy = self.date_time.timetuple().tm_yday self.plt = plot self.fig = self.plt.figure(1, figsize=(5, 4)) # Plot window size self.canvas = FigureCanvas(self, -1, self.fig) self.toolbar = NavigationToolbar(self.canvas) # matplotlib toolbar self.toolbar.Realize() # Now put all into a sizer # sizer = wx.BoxSizer(wx.VERTICAL) self.sizer = wx.BoxSizer(wx.VERTICAL) # This way of adding to sizer allows resizing # sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) # Best to allow the toolbar to resize! # sizer.Add(self.toolbar, 0, wx.GROW) self.sizer.Add(self.toolbar, 0, wx.GROW) self.SetSizer(self.sizer) self.Fit()
def __init__(self, parent, figsize=(8.0, 6.0)): super(MplPanel, self).__init__(parent, -1) self.fig = Figure(figsize, dpi=72) self.canvas = FigCanvas(self, -1, self.fig) # Since we have only one plot, we can use add_axes # instead of add_subplot, but then the subplot # configuration tool in the navigation toolbar wouldn't # work. # self.axes = self.fig.add_subplot(111) # Create the navigation toolbar, tied to the canvas # self.toolbar = NavigationToolbar(self.canvas) # # Layout with box sizers # self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas, 1, wx.EXPAND | wx.BOTTOM | wx.LEFT | wx.RIGHT, 10) self.vbox.Add(self.toolbar, 0, wx.EXPAND) self.SetSizer(self.vbox)
def create_main_panel(self): self.panel = wx.Panel(self) self.init_plot() self.canvas = FigCanvas(self.panel, -1, self.fig) self.toolbar = NavigationToolbar(self.canvas) self.pause_button = wx.Button(self.panel, -1, 'Pause') self.Bind(wx.EVT_BUTTON, self.on_pause_button, self.pause_button) self.Bind(wx.EVT_UPDATE_UI, self.on_update_pause_button, self.pause_button) self.cb_grid = wx.CheckBox(self.panel, -1, 'Show Grid', style=wx.ALIGN_RIGHT) self.Bind(wx.EVT_CHECKBOX, self.on_cb_grid, self.cb_grid) self.cb_grid.SetValue(True) self.hbox0 = wx.BoxSizer(wx.HORIZONTAL) self.hbox0.Add(self.pause_button, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.hbox0.AddSpacer(20) self.hbox0.Add(self.cb_grid, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas, 1, flag=wx.LEFT | wx.TOP | wx.GROW) self.vbox.Add(self.toolbar, 0, wx.EXPAND) self.vbox.Add(self.hbox0, 0, flag=wx.ALIGN_LEFT | wx.TOP) self.panel.SetSizer(self.vbox) self.vbox.Fit(self)
def __init__(self, parent, id=-1, dpi=None, **kwargs): wx.Panel.__init__(self, parent, id=id, **kwargs) self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2)) self.canvas = FigureCanvas(self, -1, self.figure) self.toolbar = NavigationToolbar(self.canvas) self.toolbar.Realize() self.timeslider = wx.Slider(self, value=100, minValue=0, maxValue=100, name='time') self.zoomslider = wx.Slider(self, value=50, minValue=2, maxValue=50, name='zoom') self.timeslider.Bind(wx.EVT_SLIDER, self.OnSliderScrolltime) self.zoomslider.Bind(wx.EVT_SLIDER, self.OnSliderScrollzoom) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 5, wx.EXPAND) sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) sizer.Add(self.timeslider, 0, wx.EXPAND) sizer.Add(self.zoomslider, 0, wx.EXPAND) self.SetSizer(sizer)
def download_data( self, event ): print('USGS station ID:{}'.format(self.station_ID.GetValue())) gauge=self.station_ID.GetValue() #gauge= '06803495' begin_date= self.startDate.GetValue() end_date=self.endDate.GetValue() print(type(end_date)) end_date=datetime.datetime.strptime(str(end_date).split(' ')[0], '%m/%d/%Y').strftime('%Y-%m-%d') begin_date=datetime.datetime.strptime(str(begin_date).split(' ')[0], '%m/%d/%Y').strftime('%Y-%m-%d') print(begin_date) print(end_date) gauge = '&site_no={}'.format(gauge) #period = '&period=&begin_date={}&end_date={}'.format('2000-01-01','2019-12-31') period = '&period=&begin_date={}&end_date={}'.format(begin_date, end_date) url = 'https://waterdata.usgs.gov/nwis/dv?&cb_00060=on&format=rdb{}&referred_module=sw{}'.format(gauge, period) print(url) self.dataflow = pd.read_csv(url, comment='#', header = 0, sep='\t')[1:].apply(lambda x: pd.to_numeric(x, errors='ignore') if x.name.endswith('_va') else x, axis=0) print(self.dataflow) self.dataflow.to_csv(os.path.join(self.outdir.GetPath(), self.station_ID.GetValue()), float_format='%.2f') pd.to_numeric(self.dataflow.set_index('datetime').iloc[:, 2]).plot(ax=self.axes) self.canvas = FigureCanvas(self.m_panel2, -1, self.m_panel2.figure) self.toolbar = NavigationToolbar(self.canvas)
def OnSliderScroll(self, event): """ Adjust marker size for plotting the annotations """ self.drs = [] self.updatedCoords = [] plt.close(self.fig1) self.fig1, (self.ax1f1) = plt.subplots(figsize=self.img_size, facecolor="None") self.markerSize = (self.slider.GetValue()) imagename1 = os.path.join(self.project_path, self.index[self.iter]) im = PIL.Image.open(imagename1) im_axis = self.ax1f1.imshow(im, self.colormap) if self.adjust_original_labels == False: self.ax1f1.set_title( str( str(self.iter) + "/" + str(len(self.index) - 1) + " " + str(Path(self.index[self.iter]).stem) + " " + " Threshold chosen is: " + str("{0:.2f}".format(self.threshold)))) else: self.ax1f1.set_title( str( str(self.iter) + "/" + str(len(self.index) - 1) + " " + str(Path(self.index[self.iter]).stem))) self.canvas = FigureCanvas(self.top_split, -1, self.fig1) MainFrame.plot(self, im, im_axis) self.toolbar = NavigationToolbar(self.canvas) MainFrame.confirm(self)
def __init__(self, panel): self.dpi = 80 self.fig = Figure((3.0, 2.0), dpi=self.dpi) self.canvas = FigCanvas(panel, -1, self.fig) self.gs = gridspec.GridSpec(1, 1) self.axes = [None] #self.fig.canvas.mpl_connect('pick_event',self.on_pick) self.toolbar = NavigationToolbar(self.canvas) self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.vbox.Add(self.toolbar, 0, wx.EXPAND) self.vbox.AddSpacer(10) panel.SetSizer(self.vbox) self.canvas.draw() self.pickedValue = None self.pickingActive = False self.pickedAlready = False self.tempAnnotation = None self.settings = None self.gui = None self.lift = 30 self.picker = None self.releaser = None self.pickedValue = None self.releasedValue = None self.selectedAxis = None self.atroposLeft = None self.atroposRight = None
def __init__(self, panel, settings, yourself): self.dpi = 80 self.fig = Figure((3.0, 2.0), dpi=self.dpi) self.canvas = FigCanvas(panel, -1, self.fig) self.axMs = self.fig.add_subplot(111) self.fig.canvas.mpl_connect('pick_event', self.on_pick) self.toolbar = NavigationToolbar(self.canvas) self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.vbox.Add(self.toolbar, 0, wx.EXPAND) self.vbox.AddSpacer(10) panel.SetSizer(self.vbox) self.canvas.draw() self.axMs.plot([1, 2, 3], [1, 2, 3]) self.pickedValue = None self.pickingActive = False self.pickedAlready = False self.tempAnnotation = None self.pickedPeakIdLimit = 5001 self.settings = settings self.ms = MassSpectrum() self.ms.setNormalisationType('bpi') self.gui = yourself
def __init__(self, parent, graph_title='Gradual Set: R(pulse)', xlabel='Pulse Number', ylabel='Resistance (Ohms)', dimensions=(6.0,5.0), semilogy=False): self.graph_title = graph_title self.xlabel = xlabel self.ylabel = ylabel self.semilogy = semilogy self.dpi = 100 self.fig = Figure(dimensions, dpi=self.dpi) self.canvas = FigCanvas(parent, -1, self.fig) self.axes = self.fig.add_subplot(111) self.axes.set_axis_bgcolor([.05,.05,.05]) self.axes.set_title(self.graph_title, size=12) self.axes.set_xlabel(self.xlabel, size=10) self.axes.set_ylabel(self.ylabel, size=10) # self.canvas.mpl_connect('pick_event', self.on_pick) # Create the navigation toolbar, tied to the canvas self.toolbar = NavigationToolbar(self.canvas) pylab.setp(self.axes.get_xticklabels(), fontsize=8) pylab.setp(self.axes.get_yticklabels(), fontsize=8) # plot the data as a line series, and save the reference # to the plotted line series # if semilogy: self.plot_data = self.axes.semilogy(np.array([]), 'yo-')[0] # , linewidth=1, color=(1, 1, 0),marker='o',markersize=0.5)[0] else: self.plot_data = self.axes.plot(np.array([]), 'yo-')[0]
def drawplot(self, img, img_name, itr, index, threshold, cmap, preview, keep_view=False): xlim = self.axes.get_xlim() ylim = self.axes.get_ylim() self.axes.clear() im = io.imread(img) self.ax = self.axes.imshow(im, cmap=cmap) self.orig_xlim = self.axes.get_xlim() self.orig_ylim = self.axes.get_ylim() if not preview: self.axes.set_title( str( str(itr) + "/" + str(len(index) - 1) + " " + str(Path(index[itr]).stem) + " " + " Threshold chosen is: " + str("{0:.2f}".format(threshold)))) else: self.axes.set_title( str( str(itr) + "/" + str(len(index) - 1) + " " + str(Path(index[itr]).stem))) if keep_view: self.axes.set_xlim(xlim) self.axes.set_ylim(ylim) self.figure.canvas.draw() if not hasattr(self, 'toolbar'): self.toolbar = NavigationToolbar(self.canvas) return (self.figure, self.axes, self.canvas, self.toolbar, self.ax)
def renderMatrix(self, data, groups): for item in data: row = [True, item[0], str(item[1])] self.m_dataViewListCtrl1.AppendItem(row) matplotlib.rcParams['font.sans-serif'] = ['SimHei'] matplotlib.rcParams['font.family'] = 'sans-serif' fig = plt.figure() canvas = FigCanvas(self.m_panel2, -1, fig) g = nx.Graph() # g.add_node('王豫') index = 0 for key in groups.keys(): # if index > 8: # break author_list = key.split(',') g.add_edge(author_list[0], author_list[1]) index += 1 pos = nx.spring_layout(g, k=0.15, iterations=20) # edge_labels = dict([((u, v,), g.get_edge_data(u, v)['0']) for u, v in g.edges]) # nx.draw_networkx_nodes(g, pos) # nx.draw_networkx_labels(g, pos, labels, font_size=8) # nx.draw_networkx_edge_labels(g, pos, edge_labels=edge_labels) nx.draw(g, pos, with_labels=True) nodes = g.nodes() # plt.figure(3, figsize=(30, 30)) # nx.draw(g, with_labels=True) # nx.draw(g, with_labels=True) self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.toolbar = NavigationToolbar(canvas) self.vbox.Add(self.toolbar, 0, wx.EXPAND) self.m_panel2.SetSizer(self.vbox) self.vbox.Fit(self)
def __init__(self, parent): wx.Panel.__init__(self, parent=parent, id=-1) self.Figure = matplotlib.figure.Figure(figsize=(4, 3)) self.axes = self.Figure.add_axes([0.05, 0.1, 0.9, 0.85]) self.FigureCanvas = FigureCanvas(self, -1, self.Figure) self.NavigationToolbar = NavigationToolbar(self.FigureCanvas) self.SubBoxSizer = wx.BoxSizer(wx.HORIZONTAL) self.SubBoxSizer.Add(self.NavigationToolbar, proportion=0, border=2, flag=wx.ALL | wx.EXPAND) self.TopBoxSizer = wx.BoxSizer(wx.VERTICAL) self.TopBoxSizer.Add(self.SubBoxSizer, proportion=-1, border=2, flag=wx.ALL | wx.EXPAND) self.TopBoxSizer.Add(self.FigureCanvas, proportion=-10, border=2, flag=wx.ALL | wx.EXPAND) self.SetSizer(self.TopBoxSizer) self.pylab = pylab self.pl = pylab self.pyplot = pyplot self.numpy = np self.np = np self.plt = pyplot
def __init__(self, panel, calibrants, settings, yourself): self.dpi = 80 self.fig = Figure((3.0, 2.0), dpi=self.dpi) self.canvas = FigCanvas(panel, -1, self.fig) self.axMs = self.fig.add_subplot(311) self.axTds = self.fig.add_subplot(312) self.axCal = self.fig.add_subplot(313) self.fig.canvas.mpl_connect('pick_event', self.on_pick) self.toolbar = NavigationToolbar(self.canvas) self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.vbox.Add(self.toolbar, 0, wx.EXPAND) self.vbox.AddSpacer(10) panel.SetSizer(self.vbox) self.canvas.draw() self.axMs.plot([1, 2, 3], [1, 2, 3]) self.axTds.plot([3, 2, 1], [2, 2, 2]) self.axCal.plot([1, 2, 3], [3, 2, 1]) self.pickedValue = None self.pickingActive = False self.calibrants = calibrants self.settings = settings self.gui = yourself
def drawplot(self, img, img_name, itr, index, threshold, bodyparts, cmap, preview): im = io.imread(img) ax = self.axes.imshow(im, cmap=cmap) divider = make_axes_locatable(self.axes) colorIndex = np.linspace(np.min(im), np.max(im), len(bodyparts)) cax = divider.append_axes("right", size="5%", pad=0.05) cbar = self.figure.colorbar(ax, cax=cax, spacing='proportional', ticks=colorIndex) cbar.set_ticklabels(bodyparts[::-1]) if preview == False: self.axes.set_title( str( str(itr) + "/" + str(len(index) - 1) + " " + str(Path(index[itr]).stem) + " " + " Threshold chosen is: " + str("{0:.2f}".format(threshold)))) else: self.axes.set_title( str( str(itr) + "/" + str(len(index) - 1) + " " + str(Path(index[itr]).stem))) self.figure.canvas.draw() self.toolbar = NavigationToolbar(self.canvas) return (self.figure, self.axes, self.canvas, self.toolbar)
def __init__(self, parent): wx.Panel.__init__(self, parent=parent, id=-1) self.Figure = matplotlib.figure.Figure(figsize=(20, 10)) self.axes = self.Figure.add_axes([0.1, 0.1, 0.8, 0.8]) self.FigureCanvas = FigureCanvas(self, -1, self.Figure) self.NavigationToolbar = NavigationToolbar(self.FigureCanvas) self.StaticText = wx.StaticText(self, -1, label=' 提示:先从菜单栏打开要展示的csv文件') self.SubBoxSizer = wx.BoxSizer(wx.HORIZONTAL) self.SubBoxSizer.Add(self.NavigationToolbar, proportion=0, border=2, flag=wx.ALL | wx.EXPAND) self.SubBoxSizer.Add(self.StaticText, proportion=-1, border=2, flag=wx.ALL | wx.EXPAND) self.TopBoxSizer = wx.BoxSizer(wx.VERTICAL) self.TopBoxSizer.Add(self.SubBoxSizer, proportion=-1, border=2, flag=wx.ALL | wx.EXPAND) self.TopBoxSizer.Add(self.FigureCanvas, proportion=-10, border=2, flag=wx.ALL | wx.EXPAND) self.SetSizer(self.TopBoxSizer) ###方便调用 self.pylab = pylab self.pl = pylab self.pyplot = pyplot self.numpy = np self.np = np self.plt = pyplot
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.SetBackgroundColour(BACKGROUND_COLOR) self.figure = Figure() self.canvas = FigureCanvas(self, 1, self.figure) #self.figure.set_title("Radar Target Plot") self.target_polar_subplot = self.figure.add_subplot(111, polar=True) self.target_polar_subplot.set_title('Bounding Box Target Plot') #self.target_polar_subplot.set_thetamin(-10) #self.target_polar_subplot.set_thetamax(10) self.target_polar_subplot.set_ylim(0, 150) #self.target_polar_subplot.set_ self.target_polar_subplot.set_theta_zero_location('N') self.toolbar = NavigationToolbar(self.canvas) self.toolbar.Realize() pub.subscribe(self.update_view, 'update_bounding_box') N = 20 r = 150 * np.random.rand(N) theta = 2 * np.pi * np.random.rand(N) #area = .01*r**2 colors = theta #self.target_polar_handle = self.target_polar_subplot.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha =0.75) self.target_polar_handle = self.target_polar_subplot.scatter( theta, r, marker='o', cmap='hsv', alpha=0.75) self.string_time = wx.StaticText(self, label="") self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.string_time, 0) self.sizer.Add(self.canvas, 1, wx.EXPAND) self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) self.SetSizer(self.sizer)
def __init__(self, parent, filename, welllogs, progressdialog, alllogs, id=-1, dpi=None, **kwargs): wx.Panel.__init__(self, parent, id=id, **kwargs) self.filename = filename self.figure = figure.Figure(dpi=dpi, figsize=(20, 20)) self.axes = [] subplots = 1 self.axes.append(self.figure.add_subplot(1, subplots, 1)) self.canvas = FigureCanvas(self, -1, self.figure) self.toolbar = NavigationToolbar(self.canvas) self.toolbar.Realize() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, wx.EXPAND) sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) self.SetSizer(sizer) self.welllogs = welllogs self.progressdialog = progressdialog self.alllogs = alllogs self.xplot()
def __init__(self): wx.Frame.__init__(self, None, -1) self.panel = wx.Panel(self) self.fig = plt.figure() self.canvas = FigCanvas(self.panel, -1, self.fig) # G=nx.house_graph() G=nx.dodecahedral_graph() edges=nx.draw_networkx_edges(G,pos=nx.spring_layout(G), arrows=False) # pos={0:(0,0), # 1:(1,0), # 2:(0,1), # 3:(1,1), # 4:(0.5,2.0)} node4 = nx.draw_networkx_nodes(G,pos,node_size=2000,nodelist=[4], picker=5, label=['4']) print node4 nx.draw_networkx_nodes(G,pos,node_size=3000,nodelist=[0,1,2,3],node_color='b') nx.draw_networkx_labels(G, pos) # nx.draw_networkx_edges(G,pos,alpha=0.5,width=6) plt.axis('off') self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.toolbar = NavigationToolbar(self.canvas) self.vbox.Add(self.toolbar, 0, wx.EXPAND) self.panel.SetSizer(self.vbox) self.vbox.Fit(self) self.fig.canvas.mpl_connect('pick_event', onpick) # plt.savefig("house_with_colors.png") # save as png
def __init__(self, parent): wx.Panel.__init__(self, parent=parent, id=-1) self.Figure = matplotlib.figure.Figure(figsize=(6, 6.5)) self.axes = self.Figure.add_axes([0.1, 0.1, 0.8, 0.8]) self.FigureCanvas = FigureCanvas(self, -1, self.Figure) self.NavigationToolbar = NavigationToolbar(self.FigureCanvas) #self.StaticText = wx.StaticText(self, -1, label='Show Help String') self.SubBoxSizer = wx.BoxSizer(wx.HORIZONTAL) self.SubBoxSizer.Add(self.NavigationToolbar, proportion=0, border=2, flag=wx.ALL | wx.EXPAND) #self.SubBoxSizer.Add(self.StaticText, proportion=-1, border=2, flag=wx.ALL | wx.EXPAND) self.TopBoxSizer = wx.BoxSizer(wx.VERTICAL) self.TopBoxSizer.Add(self.SubBoxSizer, proportion=-1, border=2, flag=wx.ALL | wx.EXPAND) self.TopBoxSizer.Add(self.FigureCanvas, proportion=-10, border=2, flag=wx.ALL | wx.EXPAND) self.SetSizer(self.TopBoxSizer) ###方便调用 self.pylab = pylab self.pl = pylab self.pyplot = pyplot self.numpy = np self.np = np self.plt = pyplot self.x = np.random.rand(10) self.y = np.random.rand(10) self.pltset = pltset self.datas = [] self.names = []
def drawplot(self, img, img_name, itr, index, bodyparts, cmap, keep_view=False): xlim = self.axes.get_xlim() ylim = self.axes.get_ylim() self.axes.clear() # convert the image to RGB as you are showing the image with matplotlib im = cv2.imread(img)[..., ::-1] ax = self.axes.imshow(im, cmap=cmap) self.orig_xlim = self.axes.get_xlim() self.orig_ylim = self.axes.get_ylim() divider = make_axes_locatable(self.axes) colorIndex = np.linspace(np.min(im), np.max(im), len(bodyparts)) cax = divider.append_axes("right", size="5%", pad=0.05) cbar = self.figure.colorbar(ax, cax=cax, spacing='proportional', ticks=colorIndex) cbar.set_ticklabels(bodyparts[::-1]) self.axes.set_title( str(str(itr) + "/" + str(len(index) - 1) + " " + img_name)) if keep_view: self.axes.set_xlim(xlim) self.axes.set_ylim(ylim) self.toolbar = NavigationToolbar(self.canvas) return (self.figure, self.axes, self.canvas, self.toolbar)
def create_main_panel(self): self.panel = wx.Panel(self) self.dpi = 100 self.fig = Figure((5.0,4.0),dpi = self.dpi) self.canvas = FigCanvas(self.panel,-1,self.fig) self.axes = self.fig.add_subplot(111) self.canvas.mpl_connect('pick_event',self.on_pick) self.textbox = wx.TextCtrl(self.panel,size = (200,-1),style = wx.TE_PROCESS_ENTER) self.Bind(wx.EVT_TEXT_ENTER,self.on_text_enter,self.textbox) self.drawbutton = wx.Button(self.panel,-1,"Draw!") self.cb_grid = wx.CheckBox(self.panel,-1,"Show Grid",style = wx.ALIGN_RIGHT) self.Bind(wx.EVT_CHECKBOX,self.on_cb_grid,self.cb_grid) self.slider_label = wx.StaticText(self.panel,-1,"Bar width(%):") self.slider_width = wx.Slider(self.panel,-1,value = 20,minValue = 1,maxValue = 100,style = wx.SL_AUTOTICKS|wx.SL_LABELS) self.slider_width.SetTickFreq(10,1) self.Bind(wx.EVT_COMMAND_SCROLL_THUMBTRACK,self.on_slider_width,self.slider_width) self.toolbar = NavigationToolbar(self.canvas) self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas,1,wx.LEFT | wx.TOP | wx.GROW) self.vbox.Add(self.toolbar,0,wx.EXPAND) self.vbox.AddSpacer(10) self.hbox = wx.BoxSizer(wx.HORIZONTAL) flags = wx.ALIGN_LEFT | wx.ALL | wx.ALIGN_CENTER_VERTICAL self.hbox.Add(self.textbox,0,border = 3,flag = flags) self.hbox.Add(self.drawbutton,0,border = 3,flag = flags) self.hbox.Add(self.cb_grid,0,border = 3,flag = flags) self.hbox.AddSpacer(30) self.hbox.Add(self.slider_label,0,flag = flags) self.vbox.Add(self.hbox,0,flag = wx.ALIGN_LEFT | wx.TOP)