本文整理汇总了Python中matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg.set_size_request方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasGTK3Agg.set_size_request方法的具体用法?Python FigureCanvasGTK3Agg.set_size_request怎么用?Python FigureCanvasGTK3Agg.set_size_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg
的用法示例。
在下文中一共展示了FigureCanvasGTK3Agg.set_size_request方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
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()
示例2: main
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
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
示例3: on_clicked
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
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: __init__
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
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)
示例5: PlotWidget
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
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)
示例6: __init__
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
def __init__(self, model=None, parent=None):
"""
"""
View.__init__(self, model=model, parent=parent)
self.parent_ui=pui=gsm().getUtility(
icc.rake.views.interfaces.IApplication
)
# self.ui.graph_image.clear()
self.add_actions_to_toolbar(self.ui.ag_simulation, important_only=False)
self.add_actions_to_menu(self.ui.ag_simulation, label="Simulation")
frame=self.get_main_frame()
vbox=self.ui.sim_box
fig = Figure(figsize=(5,4), dpi=120,
subplotpars=matplotlib.figure.SubplotParams(
left=0.1,
right=0.96,
bottom=0.1,
top=0.96)
)
self.ui.fig = fig
#self.ui.ax = fig.add_subplot(111)
canvas=FigureCanvas(fig)
self.ui.canvas=canvas
canvas.set_size_request(600,400)
vbox.pack_start(canvas, True, True, 0)
toolbar=DMENavigatorToolbar(canvas, self)
parent.connect("project-open", self.on_project_open)
parent.connect("project-save", self.on_project_save)
dot_widget=self.ui.dot_widget = xdot.DotWidget()
self.ui.graph_viewport.add(dot_widget)
xdot_setup=xdot.DotWindowSetup(pui.ui.window, dot_widget)
xdot_setup()
示例7: OdPredictorGui
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
class OdPredictorGui(Gtk.HBox):
def __init__(self):
super().__init__()
self.controls = ControlPanel()
self.controls.connect('new-params', self.on_new_params)
self.fig = Figure(facecolor='#e9e9e9')
self.axes = self.fig.add_subplot(1, 1, 1)
self.canvas = FigureCanvas(self.fig)
self.canvas.set_size_request(300, 300)
self.pack_start(self.controls, False, False, 0)
self.pack_start(self.canvas, True, True, 0)
self.on_new_params()
def on_new_params(self, *args):
predictor = self.controls.get_params()
predictor.plot_time_estimate(self.axes)
self.fig.tight_layout(pad=1.0)
self.canvas.draw()
示例8: testGtk
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
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()
示例9: CurrentColor
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
N1 = 160
N2 = 32
# N1=8
# N2=8
cColor = CurrentColor()
builder = Gtk.Builder()
builder.add_from_file("aff.glade")
builder.connect_signals(Handler())
sw = builder.get_object("scrolledwindow1")
# sw = Gtk.ScrolledWindow()
# win.add(sw)
ax, vals = LD.matrix_figure(N1, N2)
# lman=LD.LassoManager(ax,canvas, vals,N1,N2)
canvas = FigureCanvas(ax.figure) # a Gtk.DrawingArea
canvas.set_size_request(800, 160)
lman = LD.LassoManager(ax, canvas, vals, N1, N2)
sw.set_border_width(0)
canvas.show()
sw.add_with_viewport(canvas)
win1 = builder.get_object("window1")
win1.show_all()
Gtk.main()
示例10: rate
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
a2.spines["right"].set_position(("axes", 1.2))
a2.set_ylim(-10, 80)
a3.set_ylim(-10, 80)
a2.set_ylabel('Flow rate (Q lit/min)')
a3.set_ylabel('Eng Values')
a.set_ylabel('Pump Out: P (bar) and Q (lit/min)')
scrolledwindow1.set_border_width(5)
samples_no = 1
canvas = FigureCanvas(f) # a Gtk.DrawingArea
canvas.set_size_request(800, 450)
scrolledwindow1.add_with_viewport(canvas)
canvas.show()
if len(cfgItems) > 0:
samples_no = smtConfig.getint('General', 'samples_no')
if smtConfig.has_option('Output', 'folder'):
output_folder = smtConfig.get('Output', 'folder')
if smtConfig.has_option('Manifold_1', 'host') and smtConfig.has_option('Manifold_1', 'port'):
manifold_host_1 = smtConfig.get('Manifold_1', 'host')
manifold_port_1 = smtConfig.get('Manifold_1', 'port')
a_low= smtConfig.getint('Manifold_1', 'low')
a_high=smtConfig.getint('Manifold_1', 'high')
p_low=smtConfig.getint('Manifold_1', 'p_low')
p_high=smtConfig.getint('Manifold_1', 'p_high')
q_low=smtConfig.getint('Manifold_1', 'q_low')
q_high=smtConfig.getint('Manifold_1', 'q_high')
示例11: Window
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
class Window(object):
def __init__(self):
self.builder = Gtk.Builder()
self.builder.add_from_file('gui.glade')
self.window = self.builder.get_object('window1')
self.builder.connect_signals(self)
figure_box = self.builder.get_object('scrolledwindow1')
self.builder.get_object('spinbuttonphi_s').set_increments(0.005, 0.1)
self.builder.get_object('spinbuttonphi_p').set_increments(0.005, 0.1)
self.builder.get_object('spinbuttonL_b').set_increments(0.001, 0.1)
self.simple_ext = False
self.freeze_plot = False
self.paramp = LJPA(I_c=self.builder.get_object('spinbuttonI_c').get_value()*1e-6,
phi_dc=self.builder.get_object('spinbuttonphi_dc').get_value(),
phi_ac=self.builder.get_object('spinbuttonphi_p').get_value(),
phi_s=self.builder.get_object('spinbuttonphi_s').get_value(),
theta_p=self.builder.get_object('spinbuttontheta_p').get_value(),
C=self.builder.get_object('spinbuttonC').get_value()*1e-12,
L_s=self.builder.get_object('spinbuttonL_s').get_value()*1e-12,
f_p=self.builder.get_object('spinbuttonf_p').get_value()*1e9)
self.parameters = {'I_c' : self.builder.get_object('spinbuttonI_c').get_value()*1e-6,
'phi_dc' : self.builder.get_object('spinbuttonphi_dc').get_value(),
'phi_ac' : self.builder.get_object('spinbuttonphi_p').get_value(),
'phi_s' : self.builder.get_object('spinbuttonphi_s').get_value(),
'theta_p' : self.builder.get_object('spinbuttontheta_p').get_value(),
'C' : self.builder.get_object('spinbuttonC').get_value()*1e-12,
'L_s' : self.builder.get_object('spinbuttonL_s').get_value()*1e-12,
'f_p' : self.builder.get_object('spinbuttonf_p').get_value()*1e9}
self.builder.get_object('entry1').set_text(str(self.parameters))
# Start of Matplotlib specific code
self.fig, (self.ax1, self.ax2, self.ax3, self.ax4) = plt.subplots(4, 1, sharex=True)
# figure = Figure()#figsize=(8, 6), dpi=71)
# self.ax = figure.add_subplot(111)
f = self.get_frequency()
z = self.get_impedance(f)
re = np.real(z)
im = np.imag(z)
r = 20.*np.log10(abs((z - 50.)/(z + 50.)))
self.line_r, = self.ax1.plot(f/1e9, r)
self.line_20, = self.ax1.plot([f[0]/1e9, f[-1.]/1e9], [20., 20.], 'r--')
self.line_re, = self.ax2.plot(f/1e9, re)
self.line_50, = self.ax2.plot([f[0]/1e9, f[-1.]/1e9], [-50., -50.], 'r--')
self.line_im, = self.ax3.plot(f/1e9, im)
self.line_0, = self.ax3.plot([f[0]/1e9, f[-1.]/1e9], [0., 0.], 'r--')
self.line_abs, = self.ax4.plot(f/1e9, abs(z))
self.line_00, = self.ax4.plot([f[0]/1e9, f[-1.]/1e9], [0., 0.], 'r--')
self.ax1.set_ylabel('Gain [dB]')
self.ax2.set_ylabel('Re(Z)')
self.ax3.set_ylabel('Im(Z)')
self.ax4.set_ylabel('|Z|')
self.ax4.set_xlabel('Frequency [GHz]')
self.canvas = FigureCanvas(self.fig)
self.canvas.set_size_request(800, 600)
figure_box.add_with_viewport(self.canvas)
toolbar_box = self.builder.get_object('scrolledwindow2')
toolbar = NavigationToolbar(self.canvas, self.window)
toolbar_box.add_with_viewport(toolbar)
self.window.show_all()
Gtk.main()
def get_frequency(self):
return np.linspace(self.builder.get_object('spinbuttonf_s_start').get_value(),
self.builder.get_object('spinbuttonf_s_stop').get_value(),
self.builder.get_object('spinbuttonf_s_nb_point').get_value())*1e9
def get_impedance(self, f):
if self.builder.get_object('checkbutton3').get_active():
return self.paramp.impedance(f, simple_ext=self.simple_ext)
else:
return self.paramp.impedance(f)
def checkbutton1_toggled(self, checkbutton):
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
class SummaryView:
"""
Display the trends chart and daily summary of weather data.
"""
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()
def get_view(self) -> Gtk.Box:
"""
Returns the view object for rendering ui.
:return: View
"""
return self.view
def render(self, weather_data: list, chart_data: list):
"""
Update the GUI data.
:param weather_data: Weather data
:param chart_data: Charting data
"""
self.chart_data = chart_data
self._store.refresh_preference()
# Summary
for weather, box in zip(weather_data, self.items):
box[2].set_text(str(int(weather['temp'])) + DISPLAY_TEMP_UNITS[self._store.get_units()])
box[1].set_text(datetime.fromtimestamp(weather['ts']).strftime("%a"))
if not self.single_day_mode:
box[0].set_from_pixbuf(Icon.get_icon(weather['weather']['code']))
self.items[0][1].set_text("Yesterday" if self.single_day_mode else "Today")
# Chart
self.axis.clear()
self.axis.patch.set_visible(False)
self.axis.get_xaxis().set_ticks([])
self.axis.plot(list(range(len(chart_data))), self.chart_data, 'w-')
def hover(self, event: MouseEvent):
if event.inaxes is not self.axis:
return
x = int(event.xdata)
if x >= len(self.chart_data) or x < 0:
return
#.........这里部分代码省略.........
示例13: CampaignGraph
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
class CampaignGraph(object):
title = 'Unknown'
_graph_id = None
table_subscriptions = []
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()
@classmethod
def get_graph_id(klass):
return klass._graph_id
def make_window(self):
if self.manager == None:
self.manager = FigureManager(self.canvas, 0)
window = self.manager.window
window.set_transient_for(self.parent)
window.set_title(self.title)
return window
def mpl_signal_canvas_button_pressed(self, event):
if event.button != 3:
return
pos_func = lambda m, d: (event.x, event.y, True)
self.popup_menu.popup(None, None, None, None, event.button, Gtk.get_current_event_time())
return True
def signal_activate_popup_menu_export(self, action):
dialog = gui_utilities.UtilityFileChooser('Export Graph', self.parent)
file_name = self.config['campaign_name'] + '.png'
response = dialog.run_quick_save(file_name)
dialog.destroy()
if not response:
return
destination_file = response['target_filename']
self.figure.savefig(destination_file, format='png')
def signal_toggled_popup_menu_show_toolbar(self, widget):
if widget.get_property('active'):
self.navigation_toolbar.show()
else:
self.navigation_toolbar.hide()
def load_graph(self):
self.refresh()
def refresh(self, info_cache=None):
info_cache = (info_cache or {})
if not self.parent.rpc:
return info_cache
for table in self.table_subscriptions:
if not table in info_cache:
info_cache[table] = list(self.parent.rpc.remote_table('campaign/' + table, self.config['campaign_id']))
map(lambda ax: ax.clear(), self.axes)
self._load_graph(info_cache)
self.canvas.draw()
return info_cache
示例14: Figure
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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")
f = Figure(figsize=(5, 4), dpi=100)
a = f.add_subplot(111)
t = [1, 2, 3, 4]
s = [1, 4, 9, 16]
a.plot(t, s)
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(400, 300)
sw.add_with_viewport(canvas)
win.show_all()
Gtk.main()
示例15: Figure
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import set_size_request [as 别名]
"""
from gi.repository import Gtk
from matplotlib.figure import Figure
from numpy import arange, sin, pi
from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)
win.set_default_size(400, 300)
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()
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()