本文整理汇总了Python中matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg类的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasGTKAgg类的具体用法?Python FigureCanvasGTKAgg怎么用?Python FigureCanvasGTKAgg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FigureCanvasGTKAgg类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
class Display:
""" This class is responsible for rendering the graph in the upper portion
of the window. The data in the graph is taken from a Simulation object,
which is accessed through the main Interface object. """
# This is a color I chose to perfectly match the background of the rest of
# the interface. It might only work on my computer.
# Malingo: Yes, it only works on your computer. It depends on what gtk
# theme the user has chosen.
background = "#edecea"
def __init__(self, main):
self.main = main
pi = numpy.pi
self.abscissa = numpy.arange(-pi - .25, pi + 0.25, 0.01)
self.curve = None
self.canvas = None
def setup(self, layout):
""" This method creates the graph that is displayed on the top half of
the user interface. Currently, the axes are completely hard-coded in
this method and cannot be changed on-the-fly. """
figure = Figure(facecolor=Display.background)
axes = figure.add_subplot(111)
# In order to create a line object, a dummy line needs to be plotted.
# This line will get replaced before the GUI is shown to the user.
pi = numpy.pi
x = y = self.abscissa
self.curve = axes.plot(x, y)[0]
self.canvas = FigureCanvasGTKAgg(figure)
# The tick labels are formatted using LaTeX. This makes it possible
# to use symbols like pi.
axes.set_xticks((-pi, 0, pi))
axes.set_xticklabels((r"-\pi", "0", r"\pi"))
axes.set_xlim(-pi - 0.25, pi + 0.25)
axes.set_yticks((0, 1))
axes.set_yticklabels(("0", "1"))
axes.set_ylim((-0.1, 1.1))
layout.pack_start(self.canvas)
def update(self):
""" This method updates the graph using the new ordinate values
returned by the simulation. """
main = self.main
simulation = main.simulation
ordinate = simulation.plot(self.abscissa)
self.curve.set_ydata(ordinate)
self.canvas.draw()
开发者ID:Malingo,项目名称:DoubleSlit,代码行数:58,代码来源:interface.py
示例2: drawMonitorTest
def drawMonitorTest(self):
try:
self.builder.get_object("tmcspace").remove(self.canvastmc)
self.axistmc.clear()
except:
pass
#Add cropping
self.axistmc.imshow(self.tmonimage, cmap=cm.gray) #set scale to 0,255 somehow
#Maybe this needn't be redefined for every draw - only need draw() but not drawn often anyway
self.canvastmc=FigureCanvasGTKAgg(self.figuretmc)
self.canvastmc.draw()
self.canvastmc.show()
self.builder.get_object("tmcspace").pack_start(self.canvastmc, True, True)
for i in range(len(self.trlist)):
for cont in self.contours:
#if self.rlist[i]==cont.ritem:
#TODO remove hidden parameters here
if np.abs(self.trlist[i][0][0]-cont.ritem[0][0])<=4 and np.abs(self.trlist[i][0][1]-cont.ritem[0][1])<=4:
item=self.trlist[i]
r=Rectangle(item[0], item[1], item[2], fill=False, color="blue")
self.axistmc.add_patch(r)
#could add width, height check as well
#Always draw saved contours in blue
for ditem in self.contours:
item=ditem.ritem
开发者ID:jamesmcm,项目名称:MLTest,代码行数:30,代码来源:gui.py
示例3: openCameraConfig
def openCameraConfig(self):
try:
self.builder.get_object("ccimgbox").remove(self.canvascc)
except:
pass
ret,img = self.cap.read()
try:
img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
#cv2.imshow("newtest",img)
except:
img=np.zeros((100,100))
self.builder.get_object("resx").set_text(str(img.shape[1]))
self.builder.get_object("resy").set_text(str(img.shape[0]))
self.resolution=(img.shape[1], img.shape[0])
if img.shape[1]<self.screensize[0] and img.shape[0]<self.screensize[1]:
pass
else:
img=imresize(img, (img.shape[0]/2, img.shape[1]/2))
self.axiscc.imshow(img, cmap=cm.gray) #set scale to 0,255 somehow
self.canvascc=FigureCanvasGTKAgg(self.figurecc)
self.canvascc.draw()
self.canvascc.show()
self.builder.get_object("ccimgbox").pack_start(self.canvascc, True, True)
self.builder.get_object("cameraconfig").set_visible(1)
开发者ID:jamesmcm,项目名称:MLTest,代码行数:28,代码来源:gui.py
示例4: __init__
def __init__(self, dpi=100, x_pixel_size=500, y_pixel_size=400):
gtk.HBox.__init__(self)
# If the class is being reinitialized, we need to remove the old plot
[self.remove(child) for child in self.get_children()]
self.vbox = gtk.VBox()
self.pack_start(self.vbox)
# this is bad with labels, I have to figure out why
self.connect('size_allocate', self._full_update)
self.fig = Figure(figsize=(float(x_pixel_size)/dpi,
float(y_pixel_size)/dpi),
dpi=dpi)
self.fig.set_facecolor('white')
self.canvas = FigureCanvasGTKAgg(self.fig)
self.ax = self.fig.add_subplot(111)
self.vbox.pack_end(self.canvas)
self.canvas.connect('button_press_event', self._on_mouse_click)
self.first_update = True
self.settings = {}
self.n_lines = None
#self.line_styles = None
#self.line_colors = None
self.lines = None
self.saved_window_size = None
self.background = None
self.auto_x_scale = False
self.auto_y_scale = False
开发者ID:BBelonder,项目名称:PyExpLabSys,代码行数:28,代码来源:LivePlotsCommon.py
示例5: setup
def setup(self, layout):
""" This method creates the graph that is displayed on the top half of
the user interface. Currently, the axes are completely hard-coded in
this method and cannot be changed on-the-fly. """
figure = Figure(facecolor=Display.background)
axes = figure.add_subplot(111)
# In order to create a line object, a dummy line needs to be plotted.
# This line will get replaced before the GUI is shown to the user.
pi = numpy.pi
x = y = self.abscissa
self.curve = axes.plot(x, y)[0]
self.canvas = FigureCanvasGTKAgg(figure)
# The tick labels are formatted using LaTeX. This makes it possible
# to use symbols like pi.
axes.set_xticks((-pi, 0, pi))
axes.set_xticklabels((r"-\pi", "0", r"\pi"))
axes.set_xlim(-pi - 0.25, pi + 0.25)
axes.set_yticks((0, 1))
axes.set_yticklabels(("0", "1"))
axes.set_ylim((-0.1, 1.1))
layout.pack_start(self.canvas)
开发者ID:Malingo,项目名称:DoubleSlit,代码行数:27,代码来源:interface.py
示例6: __createNewFigure
def __createNewFigure(self):
#Setup for plotting
if self.__hasPlotNow:
self.__plotVBox.remove(self.__plotToolbar)
self.__plotVBox.remove(self.__plotCanvas)
del self.__plotToolbar
self.__plotCanvas.destroy()
del self.__plotFigure
self.__plotFigure = matplotlib.pyplot.figure()
self.__plotAxis = self.__plotFigure.add_subplot(1,1,1)
self.__plotCanvas = FigureCanvasGTKAgg(self.__plotFigure)
self.__plotCanvas.show()
self.__plotVBox.pack_start(self.__plotCanvas, expand=True)
self.__plotToolbar = NavigationToolbar2GTKAgg(self.__plotCanvas, window=self.getBaseWindow().get_parent_window())
self.__plotVBox.pack_start(self.__plotToolbar, expand=False)
self.__hasPlotNow = True
#Plot the data
self.__plotAxis.set_xlabel(self.anaInstance.xVariable)
self.__plotAxis.set_ylabel(self.anaInstance.yVariable)
self.__plotAxis.set_title("Filter: " + self.anaInstance.fVariable + " = " + str(self.anaInstance.fEquals))
matplotlib.pyplot.plot(self.anaInstance.xArray, self.anaInstance.yArray, "*")
if self.anaInstance.targetValue != None:
matplotlib.pyplot.axhline(self.anaInstance.targetValue, color="r", linestyle="--")
(xmin,xmax,ymin,ymax) = self.__plotAxis.axis()
dx = xmax-xmin; dy = ymax-ymin;
self.__plotAxis.axis([xmin-dx*0.05, xmax+dx*0.05, ymin-dy*0.05, ymax+dy*0.05])
开发者ID:kyrsjo,项目名称:AcdOpti,代码行数:29,代码来源:MetaAnalysis.py
示例7: recreate_canvas
def recreate_canvas(self, fig):
canvas = FigureCanvas(fig)
canvas.set_size_request(450, 200)
if self.canvas_frame.get_child():
self.canvas_frame.remove(self.canvas_frame.get_child())
self.canvas_frame.add(canvas)
canvas.show()
开发者ID:schlamar,项目名称:sitforc,代码行数:7,代码来源:gui.py
示例8: __init__
def __init__(self):
print 'test'
self.win = gtk.Window()
#win.connect("destroy", lambda x: gtk.main_quit())
self.win.connect("delete-event", self.hideinsteadofdelete)
self.win.set_default_size(400,300)
self.win.set_title("Embedding in GTK")
f = Figure(figsize=(5,4), dpi=100)
a = f.add_subplot(111)
t = arange(0.0,3.0,0.01)
s = sin(2*pi*t)
a.plot(t,s)
sw = gtk.ScrolledWindow()
self.win.add (sw)
# A scrolled window border goes outside the scrollbars and viewport
sw.set_border_width (10)
# policy: ALWAYS, AUTOMATIC, NEVER
sw.set_policy (hscrollbar_policy=gtk.POLICY_AUTOMATIC,
vscrollbar_policy=gtk.POLICY_ALWAYS)
canvas = FigureCanvas(f) # a gtk.DrawingArea
canvas.set_size_request(800,600)
sw.add_with_viewport (canvas)
self.win.show_all()
gtk.main()
开发者ID:badbytes,项目名称:pymeg,代码行数:28,代码来源:gtkpylab.py
示例9: Plotter
class Plotter(gtk.VBox):
def __init__(self, xlabel, ylabel, width=500, height=500, dpi=75):
"""
:type xlabel: str
:type ylabel: str
:type width: int
:type height: int
:type dpi: int
"""
gtk.VBox.__init__(self)
figure = Figure(figsize=(width, height), dpi=dpi)
self.axes = figure.add_subplot(111, xlabel=xlabel, ylabel=ylabel)
""" :type: matplotlib.axes.Axes """
self.axes.hold(False)
self.canvas = FigureCanvas(figure)
#self.canvas.mpl_connect('button_press_event', self.klick)
nav = NavigationToolbar(self.canvas, self)
self.pack_start(nav, False, False)
self.pack_start(self.canvas)
def leeren(self):
self.axes.hold(False)
def plot(self, x, y, **args):
self.axes.plot(x, y, antialiased=True, **args)
self.axes.hold(True)
def draw(self):
self.canvas.draw()
"""def klick(self, evt):
开发者ID:lustra,项目名称:SpeckView,代码行数:31,代码来源:Plotter.py
示例10: visualize
def visualize(*args, **kwargs):
"""
Method that does all magic to to with GTK.
All arguments passed to grapher.matplot.Graph
"""
logger.debug('Spawning a GTK window')
win = gtk.Window()
win.connect('destroy', lambda x: gtk.main_quit())
win.set_default_size(800,500)
win.set_title('BounceItBaby visualizer')
sw = gtk.ScrolledWindow()
win.add(sw)
# TODO: allow arrow/hjkl buttons to scroll
sw.set_policy(hscrollbar_policy=gtk.POLICY_ALWAYS,
vscrollbar_policy=gtk.POLICY_AUTOMATIC)
logger.debug('Building the Figure from data')
figure = Graph(*args, **kwargs)
canvas = FigureCanvas(figure)
# If time scale is 20 times longer than number of actors, make it 20 times
# wider than it is tall.
canvas.set_size_request(int(400 / figure.axes[0].get_data_ratio()), 400)
sw.add_with_viewport(canvas)
logger.debug('Displaying GTK window!')
win.show_all()
gtk.main()
开发者ID:xim,项目名称:bounceitbaby,代码行数:30,代码来源:gtk_grapher.py
示例11: __init__
def __init__(self,src,model,state):
self.src = src
self.model = model
self.__state = state
state.connect('selection-changed',self.update_spanner)
state.connect('selection-removed',self.remove_spanner)
xb = src.get_time_bounds()
yb = src.get_data_bounds()
figure = Figure(dpi=100)
self.plot = figure.add_subplot(111,xbound=xb,ybound=yb,autoscale_on=False)
self.plot.plot_date(src.get_time(True),src.get_data(True),'-')
if state.selection is None:
self.spanner = None
else:
vall,valr = state.selection
self.spanner = self.plot.axvspan(vall,valr,alpha=0.5)
self.ctx_spanners = dict()
FigureCanvas.__init__(self,figure)
self.mpl_connect('button_press_event',self.on_press)
self.mpl_connect('button_release_event',self.on_release)
self.mpl_connect('motion_notify_event',self.on_move)
model.connect('annotation-added',self.notice_annotation)
model.connect('annotation-removed',self.notice_annotation_removal)
model.connect('annotation-changed',self.notice_annotation_change)
for (id,color,boundl,boundr) in model.annotations():
self.notice_annotation(model,id,color,boundl,boundr)
开发者ID:hguenther,项目名称:context-annotator,代码行数:27,代码来源:display.py
示例12: __init__
class HelloMatplotlib:
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_size_request(400, 400)
self.window.set_border_width(10)
f = Figure(figsize=(5,4), dpi=100)
a = f.add_subplot(111)
t = arange(0.0,3.0,0.01)
s = sin(2*pi*t)
a.plot(t,s)
self.canvas = FigureCanvas(f)
self.canvas.show()
self.window.add(self.canvas)
self.window.show()
def delete_event(self, widget, event, data=None):
gtk.main_quit()
def destroy(self, widget, data=None):
gtk.main_quit()
def main(self):
gtk.main()
开发者ID:adamchainz,项目名称:pynsist,代码行数:27,代码来源:hellomatplotlib.py
示例13: __init__
def __init__(self, x, y, title="Graph", parent=None):
gtk.Window.__init__(self)
try:
self.set_screen(parent.get_screen())
except:
self.connect('destroy', lambda *w: self.destroy())
self.set_title(title)
self.set_default_size(800, 600)
self.set_border_width(2)
self.set_position(gtk.WIN_POS_CENTER)
box = gtk.VBox()
self.add(box)
fig = Fig(figsize=(5,4), dpi=100)
ax = fig.add_subplot(111)
ax.plot(x, y)
canvas = FigCan(fig)
canvas.mpl_connect('key_press_event', self.on_key_event)
box.pack_start(canvas)
toolbar = NavBar(canvas, self)
box.pack_start(toolbar, False, False)
self.show_all()
del box, fig, ax, canvas, toolbar
开发者ID:moyeah,项目名称:wp,代码行数:29,代码来源:wp_graph.py
示例14: __init__
def __init__(self):
self._gladefile = "neuronview.glade"
self._builder = gtk.Builder()
self._builder.add_from_file(self._gladefile)
self._builder.connect_signals(self)
self._win = self._builder.get_object("mainwindow")
self._win.resize(900, 700)
box = self._builder.get_object("box5")
self._stimulatordictview = DictView()
self._builder.get_object("scrolledwindow2").add(self._stimulatordictview)
box = self._builder.get_object("box4")
self._neurondictview = DictView()
self._builder.get_object("scrolledwindow3").add(self._neurondictview)
self.populate_comboboxes()
self._figure = Figure(figsize=(5,4), dpi=100)
canvas = FigureCanvas(self._figure)
canvas.set_size_request(200, 250)
canvas.show()
box = self._builder.get_object("box3")
bg_style = box.get_style().bg[gtk.STATE_NORMAL]
gtk_color = (bg_style.red_float, bg_style.green_float, bg_style.blue_float)
self._figure.set_facecolor(gtk_color)
box.pack_start(canvas)
self._win.show()
gtk.main()
开发者ID:JanneM,项目名称:nest-simulator,代码行数:34,代码来源:neuronview.py
示例15: __init__
def __init__(self):
# Minimal gtk initialization
self.builder = gtk.Builder()
self.builder.add_from_file("roi_image.glade")
self.builder.connect_signals(self)
# Create a matplotlib figure for the image
self.imageFigure = Figure(figsize=(5,4), dpi=100)
self.imagePlot = self.imageFigure.add_subplot(111)
# Place the matplotlib figures into a container
self.imageCanvas = FigureCanvas(self.imageFigure) # a gtk.DrawingArea
self.builder.get_object('imageViewPort').add(self.imageCanvas)
# Create a matplotlib figure for the plot
self.plotFigure = Figure(figsize=(5,4), dpi=100)
self.plotPlot = self.plotFigure.add_subplot(111)
# Place the matplotlib figures into a container
self.plotCanvas = FigureCanvas(self.plotFigure) # a gtk.DrawingArea
self.builder.get_object('plotViewPort').add(self.plotCanvas)
self.builder.get_object('lowIndexSlider').set_range(0,2047)
self.builder.get_object('lowIndexSlider').set_value(0)
self.builder.get_object('highIndexSlider').set_range(0,2047)
self.builder.get_object('highIndexSlider').set_value(2047)
self.mCurrentLowLimit = 0
self.mCurrentHighLimit = 2047
开发者ID:H-Y-S,项目名称:FIMA,代码行数:30,代码来源:roi_image.py
示例16: __init__
def __init__(self,t_from,t_to):
self.figure = Figure(figsize=(10,2), dpi=80)
self.t_from = t_from
self.t_to = t_to
self.t_diff = math.fabs(t_from - t_to)
self.axis = None
FigureCanvas.__init__(self,self.figure)
开发者ID:RTS2,项目名称:rts2-gtk,代码行数:9,代码来源:plot.py
示例17: FigureWidget
class FigureWidget(gtk.ScrolledWindow):
def __init__(self, figure):
super(FigureWidget, self).__init__()
self.set_border_width(10)
self.set_policy(hscrollbar_policy=gtk.POLICY_AUTOMATIC,
vscrollbar_policy=gtk.POLICY_ALWAYS)
self.canvas = FigureCanvas(figure)
self.canvas.set_size_request(500, 100)
self.add_with_viewport(self.canvas)
开发者ID:matze,项目名称:af,代码行数:9,代码来源:ui.py
示例18: __init__
def __init__(self, win, size, show_labels=True):
fig = Figure(figsize=(size, size))
canvas = FigureCanvas(fig) # a gtk.DrawingArea
canvas.set_size_request(500, 500)
toolbar = NavigationToolbar(canvas, win)
self.vbox = gtk.VBox()
self.vbox.pack_start(canvas)
self.vbox.pack_start(toolbar, False, False)
self.fig = fig
self.show_labels = show_labels
self.eventfiles = {}
开发者ID:taldcroft,项目名称:cygob2_imgview,代码行数:11,代码来源:imgview.py
示例19: PowerGraph
class PowerGraph(gtk.Window):
def __init__(self, powers, step=0.5, title="Power Graph", parent=None):
x = []
y = []
for power, next_power in itertools.izip(powers, powers[1:]):
u = float(power[0])
u1 = float(next_power[0])
while u < u1:
x.append(u)
y.append(float(eval(power[1])))
u += step*(u1-u)
x.append(float(powers[-1][0]))
y.append(float(eval(powers[-1][1])))
gtk.Window.__init__(self)
try:
self.set_screen(parent.get_screen())
except AttributeError:
self.connect('destroy', lambda *w: self.destroy())
if parent is not None:
self.set_parent(parent)
self.set_title(title)
self.set_destroy_with_parent(True)
self.set_default_size(600, 400)
vbox = gtk.VBox()
self.add(vbox)
figure = Figure(figsize=(5,4), dpi=100)
subplot = figure.add_subplot(111)
subplot.plot(x, y)
subplot.set_title("Power Graph")
subplot.set_xlabel("Speed (u) [m/s]")
subplot.set_ylabel("Power [kW]")
subplot.grid(True)
self.canvas = FigureCanvas(figure)
self.canvas.mpl_connect('key_press_event', self.on_key_event)
vbox.pack_start(self.canvas)
self.toolbar = NavigationToolbar(self.canvas, self)
vbox.pack_start(self.toolbar, False, False)
self.show_all()
def on_key_event(self, event):
key_press_handler(event, self.canvas, self.toolbar)
开发者ID:moyeah,项目名称:wpc,代码行数:52,代码来源:powergraph.py
示例20: graficar
def graficar(self, datos, datos1, titulo):
datos = datos # valores del tiempo de espera.
datos1 = datos1 # valores de tiempo de cpu, tiempo de llegada y numeró de procesos.
titulo = titulo
x1 = []
y1 = []
y2 = []
n = len(datos)
for i in xrange(n):
x1.append(datos1[i][0]) #Numero de proceso
y1.append(datos[i][1]) #Tiempo de espera
y2.append(datos1[i][1]) #tiempo de uso del cpu
self.win = gtk.Window()
self.win.set_default_size(600,480)
self.win.set_position(gtk.WIN_POS_CENTER)
self.win.set_title(titulo)
f = Figure(figsize=(5,4), dpi=100)
a = f.add_subplot(111)
a.plot(x1, y1, color='blue', label='(Procesos, Tiempo de espera)')
a.legend(loc = 2)
a.set_title(titulo, color='red', size=14)
a.set_xlabel(u'Número de procesos', color='red', size=14)
a.set_ylabel('Tiempo de espera ', color='red', size=14)
"""
# gráfica procesos vs tiempo de cpu
#g = Figure(figsize=(5,4), dpi=100)
b = f.add_subplot(111)
b.plot(x1, y2, color='red', label='(Procesos, Tiempo de CPU)')
b.set_xlabel(u'Número de procesos', color='red', size=14)
b.set_ylabel('Tiempo de CPU ', color='red', size=14)
"""
vbox = gtk.VBox(False, 5)
canvas = FigureCanvas(f)
canvas.show()
#canvas1 = FigureCanvas(g)
#canvas1.show()
vbox.pack_start(canvas, True, True, 0)
#vbox.pack_start(canvas1, True, True, 0)
cerrar = gtk.Button(stock=gtk.STOCK_CLOSE)
cerrar.connect("activate", self.close)
vbox.pack_start(cerrar, False, False, 0)
self.win.add(vbox)
self.win.show_all()
开发者ID:joenco,项目名称:simuproc,代码行数:52,代码来源:graficos.py
注:本文中的matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论