本文整理汇总了Python中matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg类的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg类的具体用法?Python FigureCanvasQTAgg怎么用?Python FigureCanvasQTAgg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FigureCanvasQTAgg类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
self._fig = Figure(dpi=170)
FigureCanvasQTAgg.__init__(self, self._fig)
FigureCanvasQTAgg.setSizePolicy(self,
QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding)
self._fig.subplots_adjust(left=0, right=1, top=1, bottom=0)
self._mpl_toolbar = NavigationToolbar2QTAgg(self, self)
self._mpl_toolbar.hide()
self.__taking = False
self._scale = 'log'
self._scales = OrderedDict()
self._scales['Logarithmic'] = 'log'
self._scales['Linear'] = 'linear'
self._scales['Square Root'] = 'sqrt'
self._scales['Power'] = 'power'
self._scales['Arc Sinh'] = 'arcsinh'
self._gc = None
self._upperCut = 99.75
self._lowerCut = 0.25
self._cmap = 'gray'
self._refresh_timer = QtCore.QTimer(self)
self._refresh_timer.setSingleShot(True)
self._refresh_timer.timeout.connect(self._refreshConcrete)
self.apertures = []
开发者ID:badders,项目名称:pyfitsview,代码行数:25,代码来源:fitsview.py
示例2: keyPressEvent
def keyPressEvent(self, event):
if self.redetecter:
self.detecter()
key = event.key()
txt = event.text()
modifiers = event.modifiers()
accept = True
debug("key: ", key)
if key == Qt.Key_Delete and self.select:
if shift_down(event):
self.executer("%s.cacher()" %self.select.nom)
else:
self.executer("%s.supprimer()" %self.select.nom)
elif key in (Qt.Key_Return, Qt.Key_Enter) and self.editeur.objet is not self.select:
self.editer(shift_down(event))
elif self.editeur and not self.editeur.key(key, txt, modifiers):
accept = False
if key == Qt.Key_Escape:
if self.action_en_cours is not None:
self.interrompre_action_en_cours()
elif self.interaction:
print("ESCAPE !")
self.interaction(special="ESC")
accept = True
if not accept:
FigureCanvasQTAgg.keyPressEvent(self, event)
开发者ID:wxgeo,项目名称:geophar,代码行数:29,代码来源:qtcanvas.py
示例3: MPLibWidget
class MPLibWidget(QtWidgets.QWidget):
"""
base MatPlotLib widget
"""
def __init__(self, parent=None):
super(MPLibWidget, self).__init__(parent)
self.figure = Figure()
self.canvas = FigureCanvasQTAgg(self.figure)
self.canvas.setParent(self)
self.mpl_toolbar = NavigationToolbar2QT(self.canvas, self)
self.canvas.mpl_connect('key_press_event', self.on_key_press)
self.axes = self.figure.add_subplot(111)
# self.axes.hold(False)
self.compute_initial_figure()
self.layoutVertical = QtWidgets.QVBoxLayout(self)
self.layoutVertical.addWidget(self.canvas)
self.layoutVertical.addWidget(self.mpl_toolbar)
def on_key_press(self, event):
"""not working"""
print('you pressed', event.key)
# implement the default mpl key press events described at
# http://matplotlib.org/users/navigation_toolbar.html#navigation-keyboard-shortcuts
key_press_handler(event, self.canvas, self.mpl_toolbar)
def compute_initial_figure(self):
pass
开发者ID:VDFaller,项目名称:Optical-Modeling,代码行数:33,代码来源:Main.py
示例4: mousePressEvent
def mousePressEvent(self, event):
button = event.button()
if button == Qt.LeftButton:
self.onLeftDown(event)
elif button == Qt.RightButton:
self.onRightDown(event)
else:
FigureCanvasQTAgg.mousePressEvent(self, event)
开发者ID:wxgeo,项目名称:geophar,代码行数:8,代码来源:qtcanvas.py
示例5: mouseReleaseEvent
def mouseReleaseEvent(self, event):
button = event.button()
if button == Qt.LeftButton:
self.onLeftUp(event)
elif button == Qt.RightButton:
self.onRightUp(event)
else:
FigureCanvasQTAgg.mouseReleaseEvent(self, event)
开发者ID:wxgeo,项目名称:geophar,代码行数:8,代码来源:qtcanvas.py
示例6: test_resize_qt
def test_resize_qt():
# This test just ensures that the code runs, but doesn't check for now
# that the behavior is correct.
pytest.importorskip('PyQt5')
from PyQt5.QtWidgets import QMainWindow
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5 import FigureManagerQT
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
fig = Figure()
canvas = FigureCanvasQTAgg(fig)
canvas.manager = FigureManagerQT(canvas, 0) # noqa
ax = fig.add_subplot(1, 1, 1)
canvas.draw = Mock(side_effect=canvas.draw)
from matplotlib.backends.backend_qt5 import qApp
window = QMainWindow()
window.setCentralWidget(canvas)
window.show()
x1 = np.random.normal(0, 1, 10000000)
y1 = np.random.normal(0, 1, 10000000)
a = ScatterDensityArtist(ax, x1, y1)
ax.add_artist(a)
canvas.draw()
assert not a.stale
assert canvas.draw.call_count == 1
window.resize(300, 300)
# We can't actually check that stale is set to True since it only remains
# so for a short amount of time, but we can check that draw is called twice
# (once at the original resolution then once with the updated resolution).
start = time.time()
while time.time() - start < 1:
qApp.processEvents()
assert canvas.draw.call_count == 3
assert not a.stale
start = time.time()
while time.time() - start < 1:
qApp.processEvents()
a.remove()
qApp.processEvents()
开发者ID:astrofrog,项目名称:rasterized_scatter,代码行数:55,代码来源:test_scatter_density_artist.py
示例7: LiveGraphQt4
class LiveGraphQt4(Backend):
"""Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.)."""
def show(self, delay=50):
self.canvas = FigureCanvasQTAgg(self.figure)
self.canvas.show()
self.timer = QtCore.QTimer(self.canvas)
self.timer.timeout.connect(self.run)
super().show(delay)
开发者ID:t--wagner,项目名称:pymeasure,代码行数:11,代码来源:liveplot.py
示例8: PlotWidget
class PlotWidget(QtWidgets.QWidget):
def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
self.button = QtWidgets.QPushButton("Plot")
self.button.clicked.connect(self.plot)
layout = QtWidgets.QVBoxLayout()
layout.addWidget(self.toolbar)
layout.addWidget(self.canvas)
layout.addWidget(self.button)
self.setLayout(layout)
def plot(self):
data = [x for x in range(10)]
ax = self.figure.add_subplot(111)
ax.hold(False)
ax.plot(data, "*-")
self.canvas.draw()
开发者ID:neXyon,项目名称:pynephoscope,代码行数:31,代码来源:main.py
示例9: PlotWidget
class PlotWidget(Widgets.WidgetBase):
def __init__(self, plot, width=500, height=500):
super(PlotWidget, self).__init__()
self.widget = FigureCanvas(plot.get_figure())
self.widget._resizeEvent = self.widget.resizeEvent
self.widget.resizeEvent = self.resize_event
self.plot = plot
self.logger = plot.logger
def set_plot(self, plot):
self.plot = plot
self.logger = plot.logger
self.logger.debug("set_plot called")
def configure_window(self, wd, ht):
fig = self.plot.get_figure()
fig.set_size_inches(float(wd) / fig.dpi, float(ht) / fig.dpi)
def resize_event(self, event):
rect = self.widget.geometry()
x1, y1, x2, y2 = rect.getCoords()
width = x2 - x1
height = y2 - y1
if width > 0 and height > 0:
self.configure_window(width, height)
self.widget._resizeEvent(event)
开发者ID:,项目名称:,代码行数:29,代码来源:
示例10: __init__
def __init__(self, parent=None,
width=4, height=3, dpi=100,
use_seaborn=False,
style=0, context=0):
self.seaborn = use_seaborn
if use_seaborn:
import seaborn as sns
sns.set_style(self.SEABORN_STYLE[style])
sns.set_context(self.SEABORN_CONTEXT[context])
# set matplitlib figure object
self.fig = Figure(figsize=(width, height), dpi=int(dpi))
self.axes = self.fig.add_subplot(111)
self.axes.hold(True)
# call constructor of FigureCanvas
super(Figurecanvas, self).__init__(self.fig)
self.setParent(parent)
# expand plot area as large as possible
FigureCanvas.setSizePolicy(self,
QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
self.x_min = 0
self.x_max = 30
# set color map object
self.__cm = matplotlib.cm.gist_rainbow
开发者ID:TaizoAyase,项目名称:FSECplotter2,代码行数:30,代码来源:figurecanvas.py
示例11: __init__
def __init__(self):
QWidget.__init__(self)
self.win_list=windows()
self.setFixedSize(900, 600)
self.setWindowIcon(QIcon(os.path.join(get_image_file_path(),"doping.png")))
self.setWindowTitle(_("Doping profile editor (www.gpvdm.com)"))
self.win_list.set_window(self,"doping")
self.main_vbox=QVBoxLayout()
toolbar=QToolBar()
toolbar.setIconSize(QSize(48, 48))
self.save = QAction(QIcon(os.path.join(get_image_file_path(),"save.png")), _("Save"), self)
self.save.triggered.connect(self.callback_save)
toolbar.addAction(self.save)
spacer = QWidget()
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
toolbar.addWidget(spacer)
self.help = QAction(QIcon(os.path.join(get_image_file_path(),"help.png")), _("Help"), self)
self.help.triggered.connect(self.callback_help)
toolbar.addAction(self.help)
self.main_vbox.addWidget(toolbar)
self.fig = Figure(figsize=(5,4), dpi=100)
self.ax1=None
self.show_key=True
canvas = FigureCanvas(self.fig)
#canvas.set_background('white')
#canvas.set_facecolor('white')
canvas.figure.patch.set_facecolor('white')
canvas.show()
self.main_vbox.addWidget(canvas)
self.tab = QTableWidget()
self.tab.resizeColumnsToContents()
self.tab.verticalHeader().setVisible(False)
self.tab.clear()
self.tab.setColumnCount(4)
self.tab.setSelectionBehavior(QAbstractItemView.SelectRows)
self.load()
self.build_mesh()
self.tab.cellChanged.connect(self.tab_changed)
self.main_vbox.addWidget(self.tab)
self.draw_graph()
self.setLayout(self.main_vbox)
return
开发者ID:roderickmackenzie,项目名称:gpvdm,代码行数:60,代码来源:doping.py
示例12: __init__
def __init__(self, parent=None, width=6, height=4, dpi=110):
"""
Init canvas.
"""
self.fig = Figure(figsize=(width, height), dpi=dpi)
# Here one can adjust the position of the CTX plot area.
# self.axes = self.fig.add_subplot(111)
self.axes = self.fig.add_axes([0.1, 0.1, 0.85, 0.85])
self.axes.grid(True)
self.axes.set_xlabel("(no data)")
self.axes.set_ylabel("(no data)")
FigureCanvas.__init__(self, self.fig)
layout = QVBoxLayout(parent)
layout.addWidget(self)
parent.setLayout(layout)
FigureCanvas.setSizePolicy(self,
QSizePolicy.Expanding,
QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
# next too lines are needed in order to catch keypress events in plot canvas by mpl_connect()
FigureCanvas.setFocusPolicy(self, QtCore.Qt.ClickFocus)
FigureCanvas.setFocus(self)
开发者ID:pytrip,项目名称:pytripgui,代码行数:28,代码来源:plot_volhist.py
示例13: ColorbarWidget
class ColorbarWidget(QWidget):
def __init__(self, parent=None):
super(ColorbarWidget, self).__init__(parent)
fig = Figure()
rect = 0.25, 0.05, 0.1, 0.90
self.cb_axes = fig.add_axes(rect)
self.canvas = FigureCanvas(fig)
self.setLayout(QVBoxLayout())
self.layout().addWidget(self.canvas)
self.button = QPushButton("Update")
self.layout().addWidget(self.button)
self.button.pressed.connect(self._update_cb_scale)
self._create_colorbar(fig)
def _create_colorbar(self, fig):
self.mappable = ScalarMappable(norm=SymLogNorm(0.0001, 1,vmin=-10., vmax=10000.),
cmap=DEFAULT_CMAP)
self.mappable.set_array([])
fig.colorbar(self.mappable, ax=self.cb_axes, cax=self.cb_axes)
def _update_cb_scale(self):
self.mappable.colorbar.remove()
rect = 0.25, 0.05, 0.1, 0.90
self.cb_axes = self.canvas.figure.add_axes(rect)
self.mappable = ScalarMappable(Normalize(30, 4300),
cmap=DEFAULT_CMAP)
self.mappable.set_array([])
self.canvas.figure.colorbar(self.mappable, ax=self.cb_axes, cax=self.cb_axes)
self.canvas.draw()
开发者ID:martyngigg,项目名称:sandbox,代码行数:31,代码来源:cbar.py
示例14: __init__
def __init__(self, parent=None, width=5, height=4, 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)
self.compute_initial_figure()
#
FigureCanvas.__init__(self, fig)
self.setParent(parent)
self.setStyleSheet("{background-color:transparent;border:none;}")
"""FigureCanvas.setSizePolicy(self,
QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding)"""
FigureCanvas.updateGeometry(self)
self.tootlbar = NavigationToolbar(self, parent)
self.tootlbar.hide()
self.fid = 0
self.data = []
self.index = []
开发者ID:saknayo,项目名称:sspainter,代码行数:25,代码来源:_FigurePlotModule.py
示例15: plot_data
def plot_data(self):
if not self.has_graph:
new_x = [mdates.datestr2num(x) for x in self.graph_x]
plt.xlabel('Time')
plt.ylabel('Count')
ax = self.fig.add_subplot(111)
ax.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))
ax.plot(new_x, self.graph_y, 'r-')
ax.get_xaxis().set_ticks([])
#ax.get_yaxis().set_ticks([])
self.canvas = FigureCanvas(self.fig)
self.graph_layout.addWidget(self.canvas)
self.canvas.draw()
self.has_graph = True
else:
self.graph_layout.removeWidget(self.canvas)
self.canvas.close()
self.fig.clf()
plt.xlabel('Time')
plt.ylabel('Count')
ax = self.fig.add_subplot(111)
ax.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))
new_x = [mdates.datestr2num(x) for x in self.graph_x]
ax.plot(new_x, self.graph_y, 'r-')
ax.get_xaxis().set_ticks([])
#ax.get_yaxis().set_ticks([])
self.canvas = FigureCanvas(self.fig)
self.graph_layout.addWidget(self.canvas)
self.canvas.draw()
开发者ID:jshodd,项目名称:SigmaSwiper,代码行数:29,代码来源:sigmaSwiper.py
示例16: create_canvas
def create_canvas(self): # pragma: no cover
self.fig = Figure()
canvas = FigureCanvas(self.fig)
self.ui.mainLayout.addWidget(canvas)
canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
# Add subplots
gridspec = GridSpec(2, 4)
self.map_ax = self.fig.add_subplot(
gridspec.new_subplotspec((0, 0), rowspan=2, colspan=2)
)
self.spectrum_ax = self.fig.add_subplot(
gridspec.new_subplotspec((0, 2), rowspan=1, colspan=2)
)
self.hist_ax = self.fig.add_subplot(
gridspec.new_subplotspec((1, 2), rowspan=1, colspan=1)
)
self.edge_ax = self.fig.add_subplot(
gridspec.new_subplotspec((1, 3), rowspan=1, colspan=1)
)
# Create the colorbar on the histogram axes
self.cbar = plots.draw_histogram_colorbar(ax=self.hist_ax,
cmap="viridis",
norm=Normalize(0, 1))
self.cbar.ax.set_xlabel("Map Value")
# Adjust the margins
self.fig.tight_layout(pad=0)
self.fig.canvas.draw_idle()
开发者ID:m3wolf,项目名称:xanespy,代码行数:27,代码来源:qt_map_view.py
示例17: __init__
def __init__(self):
self.fig = Figure()
FigureCanvas.__init__(self, self.fig)
self.main_plot = None
self.create_main_plot()
开发者ID:kn-bibs,项目名称:dotplot,代码行数:7,代码来源:figures_plot.py
示例18: __init__
def __init__(self, parent=None,
size = (7,3.5),
dpi = 100,
logx = False,
logy = False,
legends = True,
bw = False):
self.fig = Figure(figsize=size, dpi=dpi) #in inches
FigureCanvas.__init__(self, self.fig)
FigureCanvas.setSizePolicy(self,
qt.QSizePolicy.Expanding,
qt.QSizePolicy.Expanding)
self.curveTable = None
self.dpi=dpi
ddict = {'logx':logx,
'logy': logy,
'legends':legends,
'bw':bw}
self.ax=None
self.curveList = []
self.curveDict = {}
self.setParameters(ddict)
#self.setBlackAndWhiteEnabled(bw)
#self.setLogXEnabled(logx)
#self.setLogYEnabled(logy)
#self.setLegendsEnabled(legends)
self.xmin = None
self.xmax = None
self.ymin = None
self.ymax = None
self.limitsSet = False
开发者ID:dnaudet,项目名称:pymca,代码行数:33,代码来源:QPyMcaMatplotlibSave1D.py
示例19: __init__
def __init__(self, parent=None):
super(DoseCalc, self).__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.fig = Figure()
self.axes = self.fig.add_subplot(1, 1, 1)
self.axes.hold(False)
self.Canvas = FigureCanvas(self.fig)
self.Canvas.setParent(self.ui.plot_widget)
self.Canvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.Canvas.updateGeometry()
l = QVBoxLayout(self.ui.plot_widget)
l.addWidget(self.Canvas)
self.fig_erg = Figure()
self.axes_erg = self.fig_erg.add_subplot(1, 1, 1, projection='3d')
self.axes_erg.axis('off')
self.axes_erg.hold(False)
self.Canvas_erg = FigureCanvas(self.fig_erg)
self.Canvas_erg.setParent(self.ui.erg_widget)
self.Canvas_erg.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.Canvas_erg.updateGeometry()
l2 = QVBoxLayout(self.ui.erg_widget)
l2.addWidget(self.Canvas_erg)
开发者ID:FLaible,项目名称:DoseCalcPy,代码行数:33,代码来源:DoseCalc.py
示例20: Window
class Window(QDialog):
# https://stackoverflow.com/questions/12459811/how-to-embed-matplotlib-in-pyqt-for-dummies
def __init__(self, parent=None):
super(Window, self).__init__(parent)
# a figure instance to plot on
self.figure = plt.figure()
# this is the Canvas Widget that displays the `figure`
# it takes the `figure` instance as a parameter to __init__
self.canvas = FigureCanvas(self.figure)
# this is the Navigation widget
# it takes the Canvas widget and a parent
self.toolbar = NavigationToolbar(self.canvas, self)
# Just some button connected to `plot` method
self.button = QPushButton('Plot')
self.button.clicked.connect(self.plot)
# set the layout
layout = QVBoxLayout()
layout.addWidget(self.toolbar)
layout.addWidget(self.canvas)
layout.addWidget(self.button)
self.setLayout(layout)
def plot(self):
''' plot some random stuff '''
# random data
data = [random.random() for i in range(10)]
# instead of ax.hold(False)
self.figure.clear()
# create an axis
ax = self.figure.add_subplot(111)
# discards the old graph
# ax.hold(False) # deprecated, see above
# plot data
ax.plot(data, '*-')
# refresh canvas
self.canvas.draw()
def keyPressEvent(self, event):
# http://zetcode.com/gui/pyqt5/eventssignals/
if event.key() == QtCore.Qt.Key_Escape:
self.close()
if event.key() == QtCore.Qt.Key_Space:
global gridLayout
item = gridLayout.itemAtPosition(1,1)
w = item.widget()
w.setText("test")
开发者ID:henrythroop,项目名称:NH_Jring2,代码行数:59,代码来源:test_qt_plot.py
注:本文中的matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论