Esempio n. 1
0
    def __init__(self, figure, master):
        FigureCanvasTkAgg.__init__(self, figure, master)
        self.master = master
        self.cWidth,self.cHeight = figure.get_figwidth()*figure.dpi,\
                      figure.get_figheight()*figure.dpi
        self.b1 = "up"
        self.b2 = "up"
        self.x1old, self.y1old = None, None
        self.x2old, self.y2old = None, None
        self.yCenter = 203  # center of the psiGraph in pixels
        self.yScale = -80.  # Number of pixels from 0 to 1, takes into account reversed directions
        self.psiXlist, self.psiYlist = -1 * np.ones(
            self.cWidth), self.yCenter * np.ones(self.cWidth)
        self.VXlist, self.VYlist = -1 * np.ones(
            self.cWidth), self.yCenter * np.ones(self.cWidth)
        self.oldPsi = None  # stores psYlist and
        self.oldV = None  # VYlist  for modification
        self.get_tk_widget().bind("<Motion>", self.motion)
        self.get_tk_widget().bind("<ButtonPress-1>", self.b1down)  # left click
        self.get_tk_widget().bind("<ButtonRelease-1>", self.b1up)  # for psi

        self.get_tk_widget().bind("<ButtonPress-3>",
                                  self.b2down)  # right click
        self.get_tk_widget().bind("<ButtonRelease-3>", self.b2up)  # for V(x)

        self.get_tk_widget().bind(
            "<ButtonPress-2>", self.loadOldCurves)  # So you can extend a curve
        self.get_tk_widget().bind("<space>",
                                  lambda event: globalV.pauseUnpause())
Esempio n. 2
0
    def __init__(self, figure, master):
        FigureCanvasTkAgg.__init__(self, figure, master=master)

        self.positions_x = [0]
        self.positions_y = [0]
        self.distances_x = []
        self.distances_y = []

        self.figure = figure
        spec = gridspec.GridSpec(ncols=2, nrows=1, width_ratios=[3, 1])
        self.map_subplot = figure.add_subplot(spec[0])
        self.orientation_plot = figure.add_subplot(spec[1])
        self.map_subplot.tick_params(axis='x', labelsize=6)
        self.map_subplot.tick_params(axis='y', labelsize=6, labelrotation=90)

        self.orientation_plot.get_xaxis().set_visible(False)
        self.orientation_plot.get_yaxis().set_visible(False)
        self.orientation_plot.set_ylim(-1, 1)
        self.orientation_plot.set_xlim(-1, 1)
        self.orientation_plot.set_autoscale_on(False)

        plt.subplots_adjust(left=0,
                            bottom=0,
                            right=0.1,
                            top=0.1,
                            wspace=0,
                            hspace=0)
        self.map_subplot.plot(self.positions_x, self.positions_y)
        self.draw()
Esempio n. 3
0
 def __init__(self, parent=None, width=4, height=2, 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)
     FigureCanvas.__init__(self, fig, master=parent)
     self.show()
Esempio n. 4
0
    def __init__(self, parent):
        """Initialise"""

        # set up figure, axes
        self.parent = parent
        gs_kw = {'height_ratios': [1, 12]}
        self.fig, self.axes = plt.subplots(
            nrows=2,  #sharex=True,
            figsize=(1, 4),
            gridspec_kw=gs_kw)
        self.ax_hdr, self.ax_log = self.axes
        FigureCanvasTkAgg.__init__(self, self.fig, self.parent)

        # format axes
        self.fig.set_facecolor('w')
        for ax in self.axes:
            ax.patch.set_facecolor('w')
            ax.yaxis.set_major_formatter(plt.NullFormatter())
            ax.tick_params(labelsize=8)
        self.ax_hdr.grid(False)
        self.ax_log.invert_yaxis()
        plt.setp(self.ax_hdr.get_yticklines(), visible=False)
        plt.setp(self.ax_hdr.get_xticklines(), visible=False)
        self.fig.subplots_adjust(left=.08,
                                 right=.92,
                                 hspace=.02,
                                 bottom=.04,
                                 top=.98)
Esempio n. 5
0
 def __init__(self, master=None):
     plt.xkcd()
     self.fig = plt.figure(figsize=(12, 6), dpi=100)
     self.mainplot = self.fig.add_subplot(1, 1, 1)
     FigureCanvasTkAgg.__init__(self, self.fig, master=master)
     self.mpl_connect('key_press_event', self.keypress)
     self.draw()
Esempio n. 6
0
    def __init__(self, x, parent, *args, **kwargs):
        FigureCanvasTkAgg.__init__(self, x, parent, *args, **kwargs)

        self.popup_menu = tk.Menu(parent, tearoff=0)
        self.popup_menu.add_command(label="Maximize",
                                    command=self.toggle_slider_vis)
        self.popup_menu.add_command(label="Select All")
        popup_menu = self.popup_menu
Esempio n. 7
0
 def __init__(self, parent, packSettings, width=5, height=4, dpi=100):
     fig = Figure(figsize=(width, height), dpi=dpi)
     self.axes = fig.add_subplot(111)
     
     self._initialize_figure()
     
     FigureCanvas.__init__(self, figure=fig, master=parent)
     self.show()       
     self.get_tk_widget().pack(packSettings)
Esempio n. 8
0
 def __init__(self, f, master=None, **options):
     FigureCanvasTkAgg.__init__(self, f, master, **options)
     self.f = f
     self.a = f.add_subplot(111)
     self.a.invert_xaxis()
     self.show()
     self.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
     self.toolbar = NavigationToolbar2TkAgg(self, master)
     self.toolbar.update()
    def __init__(self,
                 master=None,
                 wavefunction=None,
                 potential=None,
                 showpotential=None,
                 heightratio=3,
                 grid=None):
        # if already have a root window (master) use it, otherwise create a new window
        if master is None:
            master = Tkinter.Tk()
        self.root = master

        self.kludge = 1  # used to force redraw of figure axes

        # store input parameters
        self.wavefunction = wavefunction
        self.potential = potential
        self.heightratio = heightratio
        self.grid = grid

        # turn on potential showing if potential is given as an argument
        if showpotential is None:
            if self.potential is not None:
                self.showpotential = True
            else:
                self.showpotential = False

        # generate pylab figure
        fig = Figure()  # generate figure object
        self.fig = fig  # store figure object for future reference
        gs = GridSpec(2, 1, height_ratios=[self.heightratio,
                                           1])  # get figure geometry
        if self.showpotential:  # do we want two graphs?
            ax = fig.add_subplot(gs[0])
            potax = fig.add_subplot(gs[1])
            try:
                self.potlines, = potax.plot(self.grid, self.potential)
            except:
                self.potlines, = potax.plot(self.potential)
            potax.set_title("potential", va="top", color="red")
            self.potax = potax
        else:
            ax = fig.add_subplot(111)
        try:
            self.rewavefunctionlines, = ax.plot(self.grid, real(wavefunction))
            self.imwavefunctionlines, = ax.plot(self.grid, imag(wavefunction))
        except:
            self.rewavefunctionlines, = ax.plot(real(wavefunction))
            self.imwavefunctionlines, = ax.plot(imag(wavefunction))
        self.ax = ax  # store pointer

        # add pylab figure to window
        FigureCanvasTkAgg.__init__(self, fig, master=master)
        self.canvas = self
        #self.canvas = FigureCanvasTkAgg(fig,master=master)
        self.canvas.draw()
        self.canvas.get_tk_widget().pack(side='top', fill='both', expand=1)
Esempio n. 10
0
    def __init__(self,grapher,parent):
        if parent is None:
            parent = Tkinter.Tk()
        parent.wm_title("PyPLAUT")
        FigureCanvasTkAgg.__init__(self,grapher.ax.get_figure(),master=parent)
        
        grapher.toolbar = NavigationToolbar2TkAgg( self, parent )
        grapher.toolbar.zoom()

        self.grapher = grapher
Esempio n. 11
0
        def __init__(self, master):

            self.fig = Figure(figsize=[5, 4], dpi=100)
            self.fig.add_subplot(111).plot()
            FigureCanvasTkAgg.__init__(self, figure=self.fig, master=master)
            self.get_tk_widget().place(anchor='center',
                                       relx=0.5,
                                       rely=0.5,
                                       relwidth=0.8,
                                       relheight=0.8)
Esempio n. 12
0
    def __init__(self, figure, parent, **options):
        FigureCanvasTkAgg.__init__(self, figure, parent, **options)
        self.figure = figure
        self.add = figure.add_subplot(111)

        self.show()
        self.get_tk_widget().grid(column=4,
                                  row=0,
                                  rowspan=9,
                                  sticky='nsew',
                                  pady=20)
Esempio n. 13
0
 def __init__(self,
              **kwargs):
     self.master = kwargs.get('master')
     self.mode = kwargs.get('mode', 'scroll')
     self.kwargs = kwargs
     self.lines = []
     self.figure = Figure()
     self.axes = self.figure.add_subplot(111)
     FigureCanvasTkAgg.__init__(self, self.figure,
                                master=self.master)
     self.tkwidget = self.get_tk_widget()
 def __init__(self, figure, parent=None, **options):
     """
     argument:
         figure: a matplotlib.figure.Figure object
     """
     FigureCanvasTkAgg.__init__(self, figure, parent, **options)
     self.figure = figure
     self.add = figure.add_subplot(111)
     # .show() was deprecated and changed to .draw(). See:
     # https://github.com/matplotlib/matplotlib/pull/9275
     self.draw()
     self.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
     self.toolbar = NavigationToolbar2Tk(self, parent)
     self.toolbar.update()
Esempio n. 15
0
    def __init__(self, x, parent, *args, **kwargs):
        FigureCanvasTkAgg.__init__(self, x, parent, *args, **kwargs)
        global axRight
        global axLeft
        global fig

        self.cursorLocation = None
        self.clickedAxes = None
        self.thisFigure = x
        thisFigure = self.thisFigure
        self.popup_menu = tk.Menu(parent, tearoff=0)
        self.popup_menu.add_command(label="Show Slider",
                                    command=self.toggle_slider_vis)
        self.popup_menu.add_command(label="Hide Table of Stats",
                                    command=self.toggle_table_of_stats)
        self.popup_menu.add_command(label="Hide Histogram",
                                    command=self.dostuff)
        self.popup_menu.add_command(label="Save as...", command=saveImage)

        self.addable_menu = tk.Menu(parent, tearoff=0)
        self.addable_menu.add_command(label="Reference Line",
                                      command=self.ref_line_wrapper)
        self.addable_menu.add_command(label="Chart Title",
                                      command=self.set_graph_title1)
        addable_menu = self.addable_menu
        self.popup_menu.add_cascade(label="Add", menu=self.addable_menu)
        # self.popup_menu.add_command(label = "")
        self.removable_menu = tk.Menu(parent, tearoff=0)
        self.removable_menu.add_command(label="Reference Lines",
                                        command=self.rem_ref_lines)
        self.removable_menu.add_command(label="Secondary Axis Ticks",
                                        command=self.dostuff)
        removable_menu = self.removable_menu
        self.popup_menu.add_cascade(label="Remove", menu=self.removable_menu)
        popup_menu = self.popup_menu

        self.popup_multi = tk.Menu(parent, tearoff=0)
        self.popup_multi.add_command(label="Maximize",
                                     command=self.maximize_wrapper)
        self.popup_multi.add_cascade(label="Add", menu=self.addable_menu)
        self.popup_multi.add_command(label="See All Stats",
                                     command=self.dostuff)
        popup_multi = self.popup_multi

        self.axpopup = tk.Menu(parent, tearoff=0)
        self.axpopup.add_command(label="Hide", command=self.toggle_slider_vis)
        self.axpopup.add_command(label="Set Cursor Values",
                                 command=self.set_slider_values)
        axpopup = self.axpopup
    def __init__(self, parent):
        self.fig = plt.figure(figsize=(3, 3))
        self.ax = plt.axes()
        self.fig.set_facecolor("#f0f0f0")
        self.ax.set_aspect('equal', adjustable='box')
        #plt.gca().invert_yaxis()
        FigureCanvasTkAgg.__init__(self, self.fig, master=parent)

        self.TX = None
        self.RX = None
        self.rect = None
        self.background = None

        self.map_dim = [0, 0]
        self.points = []
Esempio n. 17
0
    def __init__(self, seq=None, parent=None, width=18, height=6, dpi=100):
        fig = Figure(figsize=(width, height), dpi=dpi)
        fig.set_facecolor(parent['background'])

        self.axes = fig.add_subplot(111)
        # We want the axes cleared every time plot() is called
        self.axes.hold(False)

        # Store the sequence object
        self.seq = seq

        # Plot the chromatograph
        self.compute_initial_figure()
        #fig.tight_layout(rect=(0.03, 0, 0.98, 0.95))

        FigureCanvas.__init__(self, fig, master=parent)
Esempio n. 18
0
    def __init__(self, master=None, **options):
        """Extend FigureCanvasTkAgg with a Matplotlib Figure object, then add
        and pack itself plus a toolbar into the master.

        :param master: parent tkinter object
        """
        self._figure = Figure(figsize=(7, 5.6), dpi=100)
        FigureCanvasTkAgg.__init__(self, self._figure, master, **options)
        self._current_plot = self._figure.add_subplot(211)
        # self.current_plot.invert_xaxis()
        self._total_plot = self._figure.add_subplot(212)
        # self.total_plot.invert_xaxis()
        self.x_min = -1  # ppm
        self.x_max = 12  # ppm
        self.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
        self._toolbar = NavigationToolbar2TkAgg(self, master)
        self._toolbar.update()
Esempio n. 19
0
    def __init__(self, parent, **kwargs):
        FigureCanvasTkAgg.__init__(self, Figure(), master=parent, **kwargs)
        self.plt = ContourEditor(self.figure, renderer=self)
        self.cell = IntVar()
        self.step = IntVar()
        self.variable = StringVar()
        self.integral = DoubleVar()
        self.cell.trace('w', self._cell)
        self.step.trace('w', self._step)
        self.variable.trace('w', self._variable)
        self.figure.canvas.mpl_connect('button_press_event', self.onclick)

        def _pass(*args, **kwargs):
            pass

        self.cell._report_exception = _pass
        self.step._report_exception = _pass
        self.plt.delaunay = True
        self.plt.callback = self.integral.set
        self.label = None
    def __init__(self, parent):

        self.fig = Figure()  #figsize=(6, 3))
        self.fig.subplots_adjust(wspace=0.5)
        self.ax1 = None
        self.ax2 = None
        self.ax3 = None
        self.cb1 = None
        self.cb2 = None
        self.cmapbw = colors.ListedColormap(['white', 'black'])
        self.RDM_map = None
        self.detection_map = None
        self.angles_plot = []
        self.ax1background = None
        self.ax2background = None
        self.ax3background = None
        self.angles = np.arange(-90, 90.05, 0.05)
        FigureCanvasTkAgg.__init__(self, self.fig, master=parent)

        self.x = 0
        self.y = 0
Esempio n. 21
0
    def __init__(self, plot, master):
        FigureCanvasTkAgg.__init__(self, plot, master)
        self.plot = plot
        self.master = master
        self.get_tk_widget().pack(fill=tk.BOTH, expand=10, side=tk.TOP)
        self.callbacks.connect('button_press_event', self.callback)
        self.xdata = 0.0
        self.xx1 = 0.0
        self.xx2 = 0.0
        self.toolbar = NavigationToolbar2TkAgg(self, self.master)
        self.toolbar.pack(side=tk.LEFT, padx=5)
        self.toolbar.update()
        self.show()
        self.master.create_buttons()

        self.rs = RectangleSelector(self.plot.axes1, self.line_select_callback,
                                    drawtype='box', useblit=True, rectprops=dict(facecolor='red', edgecolor='black',
                                                                                 alpha=0.2, fill=True),
                                    button=[1, 3],  # don't use middle button
                                    minspanx=1, minspany=1,
                                    spancoords='data',
                                    interactive=False)
Esempio n. 22
0
    def __init__(self,figure,master):
        FigureCanvasTkAgg.__init__(self,figure,master)
        self.master = master
        self.cWidth,self.cHeight = figure.get_figwidth()*figure.dpi,\
                      figure.get_figheight()*figure.dpi
        self.b1 = "up"
        self.b2 = "up"
        self.x1old,self.y1old = None,None
        self.x2old,self.y2old = None,None
        self.yCenter = 203 # center of the psiGraph in pixels
        self.yScale = -80. # Number of pixels from 0 to 1, takes into account reversed directions
        self.psiXlist,self.psiYlist = -1*np.ones(self.cWidth),self.yCenter*np.ones(self.cWidth)
        self.VXlist,self.VYlist = -1*np.ones(self.cWidth),self.yCenter*np.ones(self.cWidth)
        self.oldPsi = None # stores psYlist and 
        self.oldV = None   # VYlist  for modification
        self.get_tk_widget().bind("<Motion>", self.motion)
        self.get_tk_widget().bind("<ButtonPress-1>", self.b1down) # left click 
        self.get_tk_widget().bind("<ButtonRelease-1>", self.b1up) # for psi

        self.get_tk_widget().bind("<ButtonPress-3>", self.b2down) # right click
        self.get_tk_widget().bind("<ButtonRelease-3>", self.b2up) # for V(x)

        self.get_tk_widget().bind("<ButtonPress-2>",self.loadOldCurves) # So you can extend a curve
        self.get_tk_widget().bind("<space>",lambda event: globalV.pauseUnpause())
Esempio n. 23
0
 def __init__(self, fig, *args, **kwargs):
     FigureCanvasTkAgg.__init__(self, fig, *args, **kwargs)
     self._fig = fig
Esempio n. 24
0
 def __init__(self, master):
     f = Figure()
     FigureCanvasTkAgg.__init__(self, f, master=master)
     self.ax = f.add_subplot(1, 1, 1)
     self.ax.set_autoscaley_on(False)  # Y fixed
Esempio n. 25
0
    def __init__(self, master, width=5, height=4, dpi=100):
        fig = Figure(figsize=(width, height), dpi=dpi)
        self.axes = fig.add_subplot(111)
        self.compute_initial_figure()

        FigureCanvas.__init__(self, fig, master)
Esempio n. 26
0
 def __init__(self,title,xlabel,ylabel,master=None, width=6, height=3, dpi=100):
     self.fig = Figure(figsize=(width,height), dpi=dpi, facecolor='k', edgecolor = 'none')
     FigureCanvasTkAgg.__init__(self,figure = self.fig,master = master)
     self.fig.subplots_adjust(bottom=0.15,left=0.1, right=0.95)
     self.setGraphSettings(title,xlabel,ylabel)
Esempio n. 27
0
 def __init__(self, figure, parent):
     FigureCanvasTkAgg.__init__(self, figure, parent)
     self.toolbar = NavigationToolbar2TkAgg(self, parent)
     self.toolbar.update()
     self.mpl_connect('key_press_event', self.on_key_event)