本文整理汇总了Python中matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg类的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasGTK3Agg类的具体用法?Python FigureCanvasGTK3Agg怎么用?Python FigureCanvasGTK3Agg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FigureCanvasGTK3Agg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plotOffHours
def plotOffHours(self):
'''
Returns a FigureCanvasGTK3Agg object that displays a graphical representation
of self._offHours
'''
(t, val) = self.orderDict(self._offHours)
t = np.array(t)
val = np.array(val)
val = val/self._STD_DAY
#plt.xkcd(scale=1, length=100, randomness=2)
f = plt.figure(figsize=(6,4), dpi=100)
a = f.add_subplot(111)
z = np.zeros(len(t))
a.fill_between(t, z, val, val > 0.0, color='green', alpha=.25, interpolate=True)
a.fill_between(t, z, val, val < 0.0, color='red', alpha=.25, interpolate=True)
a.grid(True)
f.autofmt_xdate()
# Generate X ticks
xticks = list()
xtick_labels = list()
xticks.append(t[0])
xtick_labels.append(dt.strftime(t[0], "%b %y").decode("utf-8")) # avoids problems with the accentuated months
curr_month = t[0].month
for d in t:
if d.month != curr_month :
curr_month = d.month
xticks.append(dt(day=1,month=curr_month, year=d.year))
xtick_labels.append(dt.strftime(d, "%b %y").decode("utf-8"))
a.set_xticks(xticks)
a.set_xticklabels(xtick_labels, fontsize=8)
# Generate Y ticks
yticks = np.arange(min(val), max(val), 2.5)
a.set_yticks(yticks)
canvas = FigureCanvas(f) # a gtk.DrawingArea
canvas.show()
return canvas
示例2: testGtk
def testGtk(self):
from gi.repository import Gtk
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit )
win.set_default_size(800,600)
win.set_title("Embedding in GTK")
p = Plot(self.schedule, self.executions, 300, 10, "Workoad 2")
p.addScheduleBar()
p.addTaskBars()
p.addLegend()
p.addMiscInfo()
f = p.getFigure()
sw = Gtk.ScrolledWindow()
win.add (sw)
# A scrolled window border goes outside the scrollbars and viewport
sw.set_border_width (10)
canvas = FigureCanvas(f) # a Gtk.DrawingArea
canvas.set_size_request(800,600)
sw.add_with_viewport (canvas)
win.show_all()
Gtk.main()
win2 = Gtk.Window()
win2.connect("delete-event", Gtk.main_quit )
win2.set_default_size(800,600)
win2.set_title("Embedding in GTK 2")
win2.show_all()
Gtk.main()
示例3: on_clicked
def on_clicked(self, widget, title, wid, workload):
# run schedule
wm = WorkloadManager(wid, workload)
fig = wm.runAll()
# create window
win = gtk.Window()
win.set_default_size(1024,768)
win.set_title(title)
# setup drawing area
#sw = gtk.ScrolledWindow()
canvas = FigureCanvas(fig) # a Gtk.DrawingArea
canvas.set_size_request(1024,768)
#sw.add_with_viewport(canvas)
vbox = gtk.VBox()
win.add(vbox)
#win.add(sw)
#sw.set_border_width(10)
vbox.pack_start(canvas, True, True, 0)
# Create toolbar
toolbar = NavigationToolbar(canvas, win)
vbox.pack_start(toolbar, False, False, 0)
win.show_all()
示例4: main
def main():
window = gtk.Window()
window.set_default_size(800, 600)
# matplotlib
x_vec = np.arange(-10, 10, 0.01)
y_vec = np.sin(2 * 2 * np.pi * x_vec) * 1/np.sqrt(2*np.pi) * np.exp(-(x_vec**2)/2)
#fig = plt.figure(figsize=(8.0, 6.0), dpi=100)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x_vec, y_vec)
# add the image to the window
scrolled_window = gtk.ScrolledWindow()
window.add(scrolled_window)
canvas = FigureCanvas(fig)
canvas.set_size_request(800, 600) # optional...
scrolled_window.add_with_viewport(canvas)
# main
window.connect("delete-event", gtk.main_quit) # ask to quit the application when the close button is clicked
window.show_all() # display the window
gtk.main() # GTK+ main loop
示例5: main
def main():
builder = Gtk.Builder()
builder.add_objects_from_file(os.path.join(os.path.dirname(__file__),
"mpl_with_glade3.glade"),
("window1", ""))
builder.connect_signals(Window1Signals())
window = builder.get_object("window1")
sw = builder.get_object("scrolledwindow1")
# Start of Matplotlib specific code
figure = Figure(figsize=(8, 6), dpi=71)
axis = figure.add_subplot(111)
t = np.arange(0.0, 3.0, 0.01)
s = np.sin(2*np.pi*t)
axis.plot(t, s)
axis.set_xlabel('time [s]')
axis.set_ylabel('voltage [V]')
canvas = FigureCanvas(figure) # a Gtk.DrawingArea
canvas.set_size_request(800, 600)
sw.add_with_viewport(canvas)
# End of Matplotlib specific code
window.show_all()
Gtk.main()
示例6: Plot
class Plot(Gtk.Frame):
def __init__(self, sp, refs):
Gtk.Frame.__init__(self)
self.f = Figure()
self.canvas = FigureCanvas(self.f)
self.add(self.canvas)
self.set_size_request(1024, 600)
self.f.subplots_adjust(left=0.07, right=0.98, bottom=0.05, top=0.95,
hspace=0.2, wspace=0.2)
# self.buffer = self.canvas.get_snapshot()
def decorate(self, axis, title=None, ylab=None, legend=None):
# font_prop = fm.FontProperties(fname='Humor-Sans-1.0.ttf', size=14)
if title is not None:
axis.set_title(title) # , fontproperties=font_prop)
if ylab is not None:
axis.yaxis.set_label_text(ylab) # , fontproperties=font_prop)
if legend is not None:
axis.legend(legend) # , prop=font_prop)
axis.xaxis.grid(color='k', linestyle='-', linewidth=0.2)
axis.yaxis.grid(color='k', linestyle='-', linewidth=0.2)
def update(self, sp, refs):
title = [r'$\phi$', r'$\theta$', r'$\psi$']
legend = ['Ref1', 'Ref2', 'Setpoint']
for i in range(0, 3):
axis = self.f.add_subplot(331 + i)
axis.clear()
for ref in refs:
axis.plot(sp.time, pu.deg_of_rad(ref.euler[:, i]))
axis.plot(sp.time, pu.deg_of_rad(sp.euler[:, i]))
self.decorate(axis, title[i], *(('deg', legend) if i == 0 else (None, None)))
title = [r'$p$', r'$q$', r'$r$']
for i in range(0, 3):
axis = self.f.add_subplot(334 + i)
axis.clear()
for ref in refs:
axis.plot(sp.time, pu.deg_of_rad(ref.vel[:, i]))
self.decorate(axis, title[i], 'deg/s' if i == 0 else None)
title = [r'$\dot{p}$', r'$\dot{q}$', r'$\dot{r}$']
for i in range(0, 3):
axis = self.f.add_subplot(337 + i)
axis.clear()
for ref in refs:
axis.plot(sp.time, pu.deg_of_rad(ref.accel[:, i]))
self.decorate(axis, title[i], 'deg/s2' if i == 0 else None)
self.canvas.draw()
示例7: drawZones
def drawZones(self,shape,xvalues,yvalues,xlabel,ylabel,title,color,zones=None):
logging.debug('>>')
logging.debug("Type: pie | title: %s | col: %s | xlabel: %s | ylabel: %s",
title, color, xlabel, ylabel)
self.removeVboxChildren()
figure = Figure()
logging.debug("Figure: %s", figure)
axis = figure.add_subplot(111)
labels = [_("rest")]
colors = ["#ffffff"]
for zone in reversed(zones):
labels.append(zone[3])
colors.append(zone[2])
zone_sum = [0]*6
for value in yvalues[0]:
# bisection, it's faster
if value <= zones[2][1]:
if value <= zones[4][1]:
if value <= zones[4][0]:
zone_sum[0] += 1
else:
zone_sum[1] += 1
else:
if value <= zones[3][1]:
zone_sum[2] += 1
else:
zone_sum[3] += 1
else:
if value <= zones[1][1]:
zone_sum[4] += 1
else:
zone_sum[5] += 1
if shape == "pie":
self._piePlot(axis, zone_sum, colors, labels)
elif shape == "histogram":
self._barPlot(axis, zone_sum, colors, labels)
canvas = FigureCanvasGTK(figure) # a gtk.DrawingArea
canvas.show()
for child in self.vbox.get_children():
logging.debug('Child available: %s', child)
self.vbox.pack_start(canvas, True, True, 0)
logging.debug('<<')
示例8: __init__
def __init__(self, xdata, ydata, xlabel, ylabel, title):
self.popupwin=Gtk.Window()
self.popupwin.set_size_request(600,550)
self.popupwin.set_position(Gtk.WindowPosition.CENTER)
self.popupwin.set_border_width(10)
self.xdata = xdata
self.ydata = ydata
vbox = Gtk.VBox()
self.fig=Figure(dpi=100)
self.ax = self.fig.add_subplot(111)
self.canvas = FigureCanvas(self.fig)
self.main_figure_navBar = NavigationToolbar(self.canvas, self)
self.cursor = Cursor(self.ax, color='k', linewidth=1, useblit=True)
self.canvas.mpl_connect("button_press_event",self.on_press)
self.ax.set_xlabel(xlabel, fontsize = 18)
self.ax.set_ylabel(ylabel, fontsize = 18)
self.ax.set_title(title, fontsize = 18)
self.ax.plot(self.xdata, self.ydata, 'b-', lw=2)
self.textes = []
self.plots = []
vbox.pack_start(self.main_figure_navBar, False, False, 0)
vbox.pack_start(self.canvas, True, True, 2)
self.popupwin.add(vbox)
self.popupwin.connect("destroy", self.dest)
self.popupwin.show_all()
示例9: __init__
def __init__(self, config, parent, size_request=None):
self.config = config
self.parent = parent
self.figure, ax = pyplot.subplots()
self.axes = self.figure.get_axes()
self.canvas = FigureCanvas(self.figure)
self.manager = None
if size_request:
self.canvas.set_size_request(*size_request)
self.canvas.mpl_connect('button_press_event', self.mpl_signal_canvas_button_pressed)
self.canvas.show()
self.navigation_toolbar = NavigationToolbar(self.canvas, self.parent)
self.navigation_toolbar.hide()
self.popup_menu = Gtk.Menu.new()
menu_item = Gtk.MenuItem.new_with_label('Export')
menu_item.connect('activate', self.signal_activate_popup_menu_export)
self.popup_menu.append(menu_item)
menu_item = Gtk.MenuItem.new_with_label('Refresh')
menu_item.connect('activate', lambda action: self.refresh())
self.popup_menu.append(menu_item)
menu_item = Gtk.CheckMenuItem.new_with_label('Show Toolbar')
menu_item.connect('toggled', self.signal_toggled_popup_menu_show_toolbar)
self.popup_menu.append(menu_item)
self.popup_menu.show_all()
示例10: __init__
def __init__(self):
self.builder = Gtk.Builder()
self.builder.set_translation_domain(LANG_DOM)
self.builder.add_from_file(UI_FILE)
self.builder.connect_signals(self)
self.win=self.builder.get_object('window1')
self.graf_box=self.builder.get_object('graf_box')
self.statusbar = self.builder.get_object('statusbar')
self.statusbar.push(1,_('Last access: '))
self.ui_label={}
for label in labels:
self.ui_label[label]=self.builder.get_object(label)
fig = Figure()
self.plot1 = fig.add_subplot(111)
self.plot2 = fig.add_subplot(212)
self.plot3 = fig.add_subplot(313)
self.plot3.set_position([0.055,0.06,0.93,0.24])
self.plot2.set_position([0.055,0.38,0.93,0.24])
self.plot1.set_position([0.055,0.69,0.93,0.24])
self.canvas = FigureCanvas(fig)
self.graf_box.pack_start(self.canvas,True,True,0)
self.win.show_all()
if self.get_params():
self.update_ui()
GObject.timeout_add_seconds(180,self.update_ui)
示例11: __init__
def __init__(self, sp, refs):
Gtk.Frame.__init__(self)
self.f = Figure()
self.canvas = FigureCanvas(self.f)
self.add(self.canvas)
self.set_size_request(1024, 600)
self.f.subplots_adjust(left=0.07, right=0.98, bottom=0.05, top=0.95,
hspace=0.2, wspace=0.2)
示例12: __init__
def __init__(self, plot, width=500, height=500):
super(PlotWidget, self).__init__()
self.widget = FigureCanvas(plot.get_figure())
self.plot = plot
self.logger = plot.logger
self.widget.set_size_request(width, height)
self.widget.show_all()
示例13: __init__
def __init__(self, single_day_mode: bool = False):
"""
Initialises charting and summary.
:param single_day_mode: Set to true to render
summary of single item(used in historic view).
"""
self.single_day_mode = single_day_mode
self.chart_data = []
self.view = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
self.chart = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
self.summary = Gtk.Box(spacing=10)
self.label = Gtk.Label()
self.label.set_name('f_temp')
# Dynamically create widgets.
self.items = []
for _ in range(1) if single_day_mode else range(5):
item = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
temperature = Gtk.Label()
time = Gtk.Label()
status = Gtk.Image()
temperature.set_name("f_temp")
time.set_name("f_time")
item.pack_start(temperature, False, False, 0)
item.pack_start(status, False, False, 0)
item.pack_start(time, False, False, 0)
self.items.append([status, temperature, time])
self.summary.pack_start(item, True, True, 10)
# Initializing and Formatting Charts
self.fig = Figure(figsize=(5, 1), dpi=100)
self.axis = self.fig.add_subplot(111)
self.fig.patch.set_facecolor("None")
self.axis.patch.set_visible(False)
self.axis.spines['top'].set_visible(False)
self.axis.spines['right'].set_visible(False)
self.axis.spines['bottom'].set_visible(False)
self.axis.spines['left'].set_visible(False)
self.axis.get_xaxis().set_ticks([])
self.axis.tick_params(axis='y', colors='white')
self.canvas = FigureCanvas(self.fig)
self.canvas.set_size_request(500, 100)
self.canvas.mpl_connect('motion_notify_event', self.hover)
self.canvas.mpl_connect('axes_leave_event', self.hide_label)
self.chart.pack_start(self.label, True, True, 0)
self.chart.pack_start(self.canvas, True, True, 0)
self.view.pack_start(self.chart, False, False, 20)
self.view.pack_start(self.summary, False, False, 15)
self._store = DataStore()
示例14: __init__
def __init__(self, model=None, parent=None):
#View.__init__(self, model=model, parent=parent)
if mdli.IProject.providedBy(model):
model=None
View.__init__(self, model=model, parent=parent)
self.plot_options={'show-lines':True}
self.set_axis_labels()
#self.ui=rakeviews.Ui()
self.ui.win=Gtk.Frame()
#parent_ui= ui = parent.ui #gsm().getUtility(rakeints.IApplication).ui
parent_ui= ui = gsm().getUtility(rakeints.IApplication).ui
local=rakeviews.Ui()
self.local=local
self.ui.main_frame = win = self.ui.win
win.set_shadow_type(Gtk.ShadowType.NONE)
vbox = Gtk.VBox()
win.add(vbox)
fig = Figure(figsize=(5,4), dpi=120,
subplotpars=matplotlib.figure.SubplotParams(left=0.03, right=0.96, bottom=0.03, top=0.96)
)
self.ui.fig = fig
self.ui.ax = fig.add_subplot(111)
#self.ui.ax2=self.ui.ax.twinx()
#self.ui.ay2=self.ui.ax.twiny()
canvas = FigureCanvas(fig) # a Gtk.DrawingArea
self.ui.canvas = canvas
canvas.set_size_request(600, 400)
vbox.pack_start(canvas, True, True, 0)
toolbar_ = TXRFNavigationToolbar(canvas, self)
self.ui.sb=ui.statusbar
local.msg_id=None
local.ctx_id=self.ui.sb.get_context_id("plotting")
self.ui.cid = canvas.mpl_connect('button_press_event', self.on_click)
示例15: PlotWidget
class PlotWidget(Widgets.WidgetBase):
def __init__(self, plot, width=500, height=500):
super(PlotWidget, self).__init__()
self.widget = FigureCanvas(plot.get_figure())
self.plot = plot
self.logger = plot.logger
self.widget.set_size_request(width, height)
self.widget.show_all()
def set_plot(self, plot):
self.plot = plot
self.logger = plot.logger
self.logger.debug("set_plot called")
def configure_window(self, wd, ht):
self.logger.debug("canvas resized to %dx%d" % (wd, ht))
fig = self.plot.get_figure()
fig.set_size_inches(float(wd) / fig.dpi, float(ht) / fig.dpi)