本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.__init__方法的具体用法?Python FigureCanvasQTAgg.__init__怎么用?Python FigureCanvasQTAgg.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
的用法示例。
在下文中一共展示了FigureCanvasQTAgg.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
def __init__(self, parent):
self.parent = parent
self.fig = Figure()
self.ax = self.fig.add_subplot(111)
FigureCanvas.__init__(self, self.fig)
#self.cidPress = self.mpl_connect('button_press_event', self.onClick)
#self.cidRelease = self.mpl_connect('button_release_event', self.onRelease)
#self.X = np.random.rand(5,5)
#rows,cols,self.slices = self.X.shape
#self.Y = np.random.rand(5,5)
#rows,cols,self.slices = self.X.shape
newdata = np.ones(2*2)
newarray = np.reshape(newdata, (2, 2))
self.data = newarray
#self.im = self.ax.matshow(self.X[:,:])
#self.im = self.ax.matshow(self.data)
self.update()
self.fig.canvas.draw()
self.cnt = 0
self.setupSelector()
示例2: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
def __init__(self, parent=None, width=5, height=5, dpi=72):
self.fontsize = 10
# fiugrueの生成
# self.fig = plt.figure(figsize=(width, height), dpi=72, facecolor=(1, 1, 1), edgecolor=(0, 0, 0),
# tight_layout=False)
self.fig = plt.figure(figsize=(width, height), dpi=72,tight_layout=False)
# axesハンドルの生成
self.axes = self.fig.add_subplot(111)
# 再描画では上書きしない
self.axes.hold(False)
# コンストラクタ
FigureCanvas.__init__(self, self.fig)
# 親のウィジェットを生成
self.setParent(parent)
# サイズの更新
FigureCanvas.updateGeometry(self)
# シークバーの格納
self.seakbar_handle = None
self.seakbar_xdata = [1, 1]
self.seakbar_ydata = [-1, 1]
# メインラインハンドルの格納
self.mainline_handle = None
# 画像の初期表示
self.compute_initial_fiugre()
示例3: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
def __init__(self, parent=None, width=5, height=4, dpi=100):
self.fig = Figure(figsize=(width, height), dpi=dpi)
FigureCanvasQTAgg.__init__(self, self.fig)
self.setParent(parent)
FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
示例4: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
def __init__(self, figure = 1):
self.QWP = np.matrix([[ np.exp(1.j*pi/4) , 0],\
[ 0 , np.exp(-1.j*pi/4)]])
fig_1, fig_2 = plot_ellipse( Rotate(self.QWP,-pi/4)*\
np.matrix([[np.cos(-3*pi/8)],\
[np.sin(-3*pi/8)]],\
dtype = 'complex'), \
show = False, retrieve = True)
if figure ==1:
self.fig = fig_1
elif figure == 2:
self.fig = fig_2
else:
raise ValueError("Oops! That was no valid number. Try again...")
self.fig.hold(False)
FigureCanvas.__init__(self, self.fig)
FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
示例5: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
def __init__(self, parent=None, width=5, height=4, dpi=100):
self.fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = self.fig.add_subplot(111)
i = self.axes.imshow(np.outer(np.linspace(0, 1, 10), np.linspace(0, 2, 10)), zorder=1)
self.cbar = self.fig.colorbar(i)
# We want the axes cleared every time plot() is called
# self.axes.hold(False)
#
FigureCanvas.__init__(self, self.fig)
self.setParent(parent)
FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
self.crosshairs_x = 0
self.crosshairs_y = 0
self.bg_rect = Rectangle((0, 0), 0, 0, facecolor="blue", edgecolor="blue", alpha=0.3, zorder=8)
self.axes.add_patch(self.bg_rect)
self.signal_rect = Rectangle((0, 0), 0, 0, facecolor="red", edgecolor="red", alpha=0.3, zorder=9)
self.axes.add_patch(self.signal_rect)
self.anno = spot_picker.Annotate(self.axes)
self.draw()
示例6: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
def __init__(self, Maskable=False):
QtCore.QObject.__init__(self)
# Member elements for storing image formatting parameters
self.circles = []
self.cadj = lambda x: x
self.filterstack = []
self.CMap = 'gray'
self.data = []
self.im = None
self.cbar = None
self.aspectRatio = None
self.minMax = None
self.mask = None
self.maskable = Maskable
# Setup the canvas and axes
self.fig = Figure()
self.ax = self.fig.add_subplot(111, aspect='equal')
self.ax.set_axis_off()
# Need to understand what this actually does....
FigureCanvasQTAgg.__init__(self, self.fig)
FigureCanvasQTAgg.setSizePolicy(self, QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvasQTAgg.updateGeometry(self)
self.fig.canvas.mpl_connect('button_press_event', self._plotClick)
示例7: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
def __init__(self):
"""Constructor"""
# Create the figure in the canvas
self.fig = Figure()
self.ax = self.fig.add_subplot(111)
FigureCanvas.__init__(self, self.fig)
# generates first "empty" plot
t = [0.0]
e = [0.0]
self.line, = self.ax.plot(t,
e,
color="black",
linestyle="-",
linewidth=1.0)
# Set some options
self.T = {{L}} / {{U}}
self.Ek = {{E_KIN}}
self.ax.grid()
self.ax.set_xlim(0, 10.0)
self.ax.set_ylim(0.0, 1.1)
self.ax.set_autoscale_on(False)
self.ax.set_xlabel(r"$t U / L$", fontsize=21)
self.ax.set_ylabel(r"$\mathcal{E}_{k}(t) / \mathcal{E}_{k}(0)$", fontsize=21)
# force the figure redraw
self.fig.canvas.draw()
# call the update method (to speed-up visualization)
self.timerEvent(None)
# start timer, trigger event every 1000 millisecs (=1sec)
self.timer = self.startTimer(1000)
示例8: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
def __init__(self, parent):
self.fig = matplotlib.figure.Figure()
self.list_of_signals = []
self.list_of_subplots = []
self.sub_plot_number = 0
self.grid_spec = gridspec.GridSpec(5, 1)
#self.fig.gca().xaxis.set_major_formatter(
# mdates.DateFormatter('%m/%d/%Y'))
#self.fig.gca().xaxis.set_major_locator(
# mdates.DayLocator())
FigureCanvasQTAgg.__init__(self, self.fig)
self.setParent(parent)
#self.axes = self.fig.add_subplot(self.grid_spec[0])
#self.axes = self.fig.add_subplot(111)
# self.axes.set_ylabel("Y-Axis")
# self.axes.set_xlabel("X-Axis")
# we define the widget as expandable
FigureCanvasQTAgg.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
# notify the system of updated policy
FigureCanvasQTAgg.updateGeometry(self)
示例9: _setup_plot
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
def _setup_plot(self):
# Image setup
self.fig = Figure()
FigureCanvas.__init__(self, self.fig)
# Create plot, set x and y axes
ax = self.fig.add_subplot(111)
ax.set_ylim(0, 100)
# Build up timestamps
base = datetime.datetime.now()
date_ranges = [base - datetime.timedelta(seconds=x) for x in range(0,self.window_size)]
for pin in range(5):
sensor_values = [0] * self.window_size
s_plot, = ax.plot(date_ranges,sensor_values, label="Analog {}".format(pin))
# Add the ax and plot to our monitor
self.sensor_readings[pin] = sensor_values
plot_dict = {'plot': s_plot, 'ax': ax}
self.sensor_plots[pin] = plot_dict
# Show legend
ax.legend()
# Fix date formatting
self.fig.autofmt_xdate();
# Draw the initial canvas
self.fig.canvas.draw()
示例10: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
def __init__(self, dataGenerator, dtTimer=1000, ylim=None, xlim=None, startsWithZeroZero=False, title=''):
self.fig = Figure()
self.ax = self.fig.add_subplot(111)
FigureCanvas.__init__(self, self.fig)
self.title = title
self.dataGen = dataGenerator
x, t = self.dataGen.next()
self.setTitle(t)
self.counter = 1
self.width = 0.8
self.locs = np.arange(len(x))
self.bars = self.ax.bar(self.locs, x, self.width, color='#6a7ea6')
if not ylim: ylim = []
if not xlim: xlim = []
if (startsWithZeroZero):
if (ylim):
ylim[0] = 0
else:
ylim = [0, max(x * 1.1)]
if (xlim):
xlim[0] = -0.5
else:
xlim = [-0.5, len(x)]
if (ylim): self.ax.set_ylim(ylim[0], ylim[1])
if (xlim): self.ax.set_xlim(xlim[0], xlim[1])
self.fig.canvas.draw()
self.show()
self.timer = self.startTimer(dtTimer)
示例11: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
def __init__(self, ui, parent=None, width=5,
height=4, dpi=100):
"""Creates a new MplCanvas
Parameters
----------
ui: the application's ui
Returns
-------
a new MplCanvas
"""
self.function_updater = FunctionUpdater(ui)
self.quad_updater = QuadUpdater(ui, self.function_updater)
# Create a matplotlib figure
self.fig = Figure(figsize=(width, height), dpi=dpi)
# Initialize the parent class
FigureCanvas.__init__(self, self.fig)
self.setParent(parent)
FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
# Register the update_figure function with the update button
update_button = ui.update_button
update_button.clicked.connect(self.update_figure)
# Call update_figure for the first time to initialize
# the graph
self.update_figure()
示例12: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
def __init__(self,parent=None,width=5,height=4,dpi=100):
figure = Figure(figsize=(width,height),dpi=dpi)
FigureCanvas.__init__(self,figure)
self.setParent(parent)
self.axes = figure.add_subplot(111)
self.axes.hold(False)
self.axeX = [0]
示例13: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
def __init__(self, map_, width, height, parent=None, dpi=100, **matplot_args): # pylint: disable=W0613
# self._widthHint = width
# self._heightHint = height
self._origMap = map_
self._map = map_.resample((width, height))
# Old way (segfaults in some environements)
# self.figure = self._map.plot_simple(**matplot_args)
# FigureCanvas.__init__(self, self.figure)
self.figure = Figure()
self._map.plot(figure=self.figure, basic_plot=True, **matplot_args)
self.axes = self.figure.gca()
FigureCanvas.__init__(self, self.figure)
# How can we get the canvas to preserve its aspect ratio when expanding?
# sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
# sizePolicy.setHeightForWidth(True)
# self.setSizePolicy(sizePolicy)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
self.setSizePolicy(sizePolicy)
self.setMinimumSize(QtCore.QSize(width, height))
self.setMaximumSize(QtCore.QSize(width, height))
示例14: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
def __init__(self, parent, comp, elstrlist, width=3, dpi=100):
self.comp=comp
self.cart=cart_comp(comp)
compdist=compdistarr_comp(self.comp)
mincompdist=numpy.min(compdist[compdist>0.])
self.clickradius=max(.02, mincompdist/2.0)
self.elstrlist=elstrlist
self.widthpix=width*dpi
self.fig = Figure(figsize=(width/.866, width), dpi=dpi)
FigureCanvas.__init__(self, self.fig)
self.setParent(parent)
self.axes = self.fig.add_subplot(111, aspect=.866, frame_on=False)
self.pixpercomp=self.widthpix
#self.axes.set_axis_bgcolor('w') #this doesn't seem to work
self.axesformat()
# We want the axes cleared every time plot() is called
self.axes.hold(False)
self.mpl_connect('button_press_event', self.myclick)
self.inxvals=[]
self.inzvals=[]
self.exxvals=[]
self.exzvals=[]
self.includelist=[]
self.excludelist=[]
FigureCanvas.setSizePolicy(self, QSizePolicy.Fixed, QSizePolicy.Fixed)
FigureCanvas.updateGeometry(self)
示例15: __init__
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import __init__ [as 别名]
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