本文整理汇总了Python中pyqtgraph.AxisItem方法的典型用法代码示例。如果您正苦于以下问题:Python pyqtgraph.AxisItem方法的具体用法?Python pyqtgraph.AxisItem怎么用?Python pyqtgraph.AxisItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph
的用法示例。
在下文中一共展示了pyqtgraph.AxisItem方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generatePicture
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import AxisItem [as 别名]
def generatePicture(self):
## pre-computing a QPicture object allows paint() to run much more quickly,
## rather than re-drawing the shapes every time.
self.picture = QtGui.QPicture()
p = QtGui.QPainter(self.picture)
p.setPen(pg.mkPen(color='w', width=0.4)) # 0.4 means w*2
a = pg.AxisItem('bottom', pen=None, linkView=None, parent=None, maxTickLength=-5, showValues=True)
a.setFixedWidth(1)
a.setWidth(1)
a.setLabel(show=True)
a.setGrid(grid=True)
labelStyle = {'color': '#FFF', 'font-size': '14pt'}
a.setLabel('label text', units='V', **labelStyle)
# w = (self.data[1][0] - self.data[0][0]) / 3.
w = 0.2
for (t, open, close, min, max) in self.data:
p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max))
if open > close:
p.setBrush(pg.mkBrush('g'))
else:
p.setBrush(pg.mkBrush('r'))
p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open))
pg.setConfigOption('leftButtonPan', False)
p.end()
示例2: __init__
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import AxisItem [as 别名]
def __init__(self, xdict, *args, **kwargs):
pg.AxisItem.__init__(self, *args, **kwargs)
self.minVal = 0
self.maxVal = 0
self.xdict = xdict
self.x_values = np.asarray(xdict.keys())
self.x_strings = xdict.values()
self.setPen(color=(255, 255, 255, 255), width=0.8)
self.setStyle(tickFont = QFont("Roman times",10,QFont.Bold),autoExpandTextSpace=True)
# 更新坐标映射表
#----------------------------------------------------------------------
示例3: tickStrings
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import AxisItem [as 别名]
def tickStrings(self, values, scale, spacing):
strns = []
rng = max(values)-min(values)
#if rng < 120:
# return pg.AxisItem.tickStrings(self, values, scale, spacing)
if rng < 3600*24:
string = '%H:%M:%S'
label1 = '%b %d -'
label2 = ' %b %d, %Y'
elif rng >= 3600*24 and rng < 3600*24*30:
string = '%d'
label1 = '%b - '
label2 = '%b, %Y'
elif rng >= 3600*24*30 and rng < 3600*24*30*24:
string = '%b'
label1 = '%Y -'
label2 = ' %Y'
elif rng >=3600*24*30*24:
string = '%Y'
label1 = ''
label2 = ''
for x in values:
try:
strns.append(time.strftime(string, time.localtime(x)))
except ValueError: ## Windows can't handle dates before 1970
strns.append('')
try:
label = time.strftime(label1, time.localtime(min(values)))+time.strftime(label2, time.localtime(max(values)))
except ValueError:
label = ''
#self.setLabel(text=label)
return strns
示例4: __init__
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import AxisItem [as 别名]
def __init__(self, xdict, *args, **kwargs):
pg.AxisItem.__init__(self, *args, **kwargs)
self.minVal = 0
self.maxVal = 0
# 序列 <= > 时间
self.xdict = OrderedDict()
self.xdict.update(xdict)
# 时间 <=> 序列
self.tdict = OrderedDict([(v,k) for k,v in xdict.items()])
self.x_values = np.asarray(xdict.keys())
self.x_strings = list(xdict.values())
self.setPen(color=(255, 255, 255, 255), width=0.8)
self.setStyle(tickFont = QtGui.QFont("Roman times",10,QtGui.QFont.Bold),autoExpandTextSpace=True)
示例5: tickStrings
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import AxisItem [as 别名]
def tickStrings(self, values, scale, spacing):
strns = []
rng = max(values) - min(values)
# if rng < 120:
# return pg.AxisItem.tickStrings(self, values, scale, spacing)
if rng < 3600 * 24:
string = '%H:%M:%S'
label1 = '%b %d -'
label2 = ' %b %d, %Y'
elif rng >= 3600 * 24 and rng < 3600 * 24 * 30:
string = '%d'
label1 = '%b - '
label2 = '%b, %Y'
elif rng >= 3600 * 24 * 30 and rng < 3600 * 24 * 30 * 24:
string = '%b'
label1 = '%Y -'
label2 = ' %Y'
elif rng >= 3600 * 24 * 30 * 24:
string = '%Y'
label1 = ''
label2 = ''
for x in values:
try:
strns.append(time.strftime(string, time.localtime(x)))
except ValueError: ## Windows can't handle dates before 1970
strns.append('')
try:
label = time.strftime(label1, time.localtime(min(values))) + time.strftime(label2,
time.localtime(max(values)))
except ValueError:
label = ''
# self.setLabel(text=label)
return strns
示例6: __init__
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import AxisItem [as 别名]
def __init__(self, xdict, *args, **kwargs):
pg.AxisItem.__init__(self, *args, **kwargs)
self.x_values = np.asarray(xdict.keys())
self.x_strings = xdict.values()
示例7: __init__
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import AxisItem [as 别名]
def __init__(self, xdict, *args, **kwargs):
pg.AxisItem.__init__(self, *args, **kwargs)
self.xdict = xdict
示例8: __init__
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import AxisItem [as 别名]
def __init__(self, xdict, *args, **kwargs):
pg.AxisItem.__init__(self, *args, **kwargs)
self.minVal = 0
self.maxVal = 0
self.xdict = xdict
self.x_values = np.asarray(xdict.keys())
self.x_strings = xdict.values()
self.setPen(color=(255, 255, 255, 255), width=0.8)
self.setStyle(tickFont=QtGui.QFont("Roman times", 10, QtGui.QFont.Bold), autoExpandTextSpace=True)
# 更新坐标映射表
# ----------------------------------------------------------------------
示例9: _refresh_multi_axis
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import AxisItem [as 别名]
def _refresh_multi_axis(self):
""" If linked axis' are used, setup and link them """
d = self.declaration
#: Create a separate viewbox
self.viewbox = pg.ViewBox()
#: If this is the first nested plot, use the parent right axis
_plots = [c for c in self.parent().children() if isinstance(c,AbstractQtPlotItem)]
i = _plots.index(self)
if i==0:
self.axis = self.widget.getAxis('right')
self.widget.showAxis('right')
else:
self.axis = pg.AxisItem('right')
self.axis.setZValue(-10000)
#: Add new axis to scene
self.widget.layout.addItem(self.axis,2,i+2)
#: Link x axis to the parent axis
self.viewbox.setXLink(self.widget.vb)
#: Link y axis to the view
self.axis.linkToView(self.viewbox)
#: Set axis label
self.axis.setLabel(d.label_right)
#: Add Viewbox to parent scene
self.parent().parent_widget().scene().addItem(self.viewbox)
示例10: add_1d_view
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import AxisItem [as 别名]
def add_1d_view(self):
"""
Adds a 1d view to TimeSeriesWidget where you can plot and add items on it.
"""
# To customize the plot axises, create new ones.
x_axis = pg.AxisItem('bottom') # x-axis
x_axis.enableAutoSIPrefix(enable=False) # Prevent automatic SI
# prefix scaling on this axis.
x_axis.setGrid(100) # the alpha value of grids on x-axis
y_axis = pg.AxisItem('left') # x-axis
y_axis.enableAutoSIPrefix(enable=False) # Prevent automatic SI
# prefix scaling on this axis.
axis_items = {'left': y_axis, 'bottom': x_axis}
# add plot
self.zoom_selection = self.centralWidget.addPlot(axisItems=axis_items)
# disable the mouse events and menu events
self.zoom_selection.setMouseEnabled(x=False, y=False)
self.zoom_selection.setMenuEnabled(False)
# initialize a cursor object. Height of cursor is 20000.
self.vline = pg.ROI(pos=[0, 0], size=[0, 20000], angle=0,
pen=CURSOR_PEN)
self.zoom_selection.addItem(self.vline) # add item to plot area
# add y-axis region
self.right_axis = self.centralWidget.addPlot(row=0, col=1)
# disable the mouse events and menu events
self.right_axis.setMouseEnabled(x=False, y=False)
self.right_axis.setMenuEnabled(False)
self.right_axis.setMaximumWidth(125) # maximum width 125
self.right_axis.setContentsMargins(0, 0, 0, 40) # set 40 left margin
self.right_axis.hideAxis(axis="left") # hide left-axis
self.right_axis.hideAxis(axis="bottom") # hide botton-axis
self.right_axis.setYRange(0, 20000, padding=0)
# show right axis
self.right_axis.setLabel(axis="right", text="Frequency (Hz)")
# initialize a linear region item
orientation = pg.LinearRegionItem.Horizontal # set the item horizontal
self.region_yaxis = pg.LinearRegionItem(values=[0, 20000],
brush=YAXIS_BRUSH,
orientation=orientation,
bounds=[0, 20000])
self.right_axis.addItem(self.region_yaxis) # add item to right axis
# set region changed signal to set y axis range in the plot
self.region_yaxis.sigRegionChangeFinished.connect(
self.change_yaxis_range)
示例11: __init__
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import AxisItem [as 别名]
def __init__(self, sandbox, *args, **kwargs):
pg.GraphicsLayoutWidget.__init__(self, **kwargs)
self.sandbox = sandbox
self.plots = [
DisplacementPlot(
sandbox,
title='Scene Displacement',
component=lambda m: m.reference.scene.displacement),
DisplacementPlot(
sandbox,
title='Model Residual',
component=lambda m: m.reference.difference)]
self.plots[-1].addHintText()
self._mov_sig = pg.SignalProxy(
self.scene().sigMouseMoved,
rateLimit=60, slot=self.mouseMoved)
for ip, plt in enumerate(self.plots):
row = ip / 2
col = ip % 2 + 1
self.addItem(plt, row=row, col=col)
plt.showGrid(x=True, y=True)
plt.hideAxis('bottom')
plt.hideAxis('left')
plt.vb.border = pg.mkPen(50, 50, 50)
if ip != 0:
plt.setXLink(self.plots[0])
plt.setYLink(self.plots[0])
def getAxis(plt, orientation, label):
axis = pg.AxisItem(
orientation=orientation,
linkView=plt.vb)
axis.setLabel(label, units='m')
return axis
plts = self.plots
self.addItem(getAxis(plts[0], 'left', 'Northing'), row=0, col=0)
self.addItem(getAxis(plts[1], 'left', 'Northing'), row=1, col=0)
self.addItem(getAxis(plts[0], 'bottom', 'Easting'), row=2, col=1)
self.addItem(getAxis(plts[1], 'bottom', 'Easting'), row=2, col=2)
示例12: _refresh_plot
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import AxisItem [as 别名]
def _refresh_plot(self):
import numpy as np
import pyqtgraph as pg
from pyqtgraph import opengl as gl
self._create_grid()
n = 51
x = self.declaration.x
y = self.declaration.y
for i in range(n):
yi = np.array([y[i]]*100)
d = (x**2 + yi**2)**0.5
z = 10 * np.cos(d) / (d+1)
pts = np.vstack([x,yi,z]).transpose()
plt = gl.GLLinePlotItem(pos=pts, color=pg.glColor((i,n*1.3)), width=(i+1)/10., antialias=True)
self.widget.addItem(plt)
# def set_data(self,data):
# self.widget.plotItem.clear()
# if self._views:
# for view in self._views:
# view.clear()
#
# views = []
# i = 0
# if self.declaration.multi_axis:
# for i,plot in enumerate(data):
# if i>3:
# break
# if 'pen' not in plot:
# plot['pen'] = self._colors[i]
# if i>0:
# view = ViewBox()
# views.append(view)
# self.widget.plotItem.scene().addItem(view)
# if i==1:
# axis = self.widget.plotItem.getAxis('right')
# elif i>1:
# axis = AxisItem('right')
# axis.setZValue(-10000)
# self.widget.plotItem.layout.addItem(axis,2,3)
# axis.linkToView(view)
# view.setXLink(self.widget.plotItem)
# view.addItem(PlotCurveItem(**plot))
# else: #view.setYLink(self.widget.plotItem)
# self.widget.plot(**plot)
# if i>0:
# def syncViews():
# for v in views:
# v.setGeometry(self.widget.plotItem.vb.sceneBoundingRect())
# v.linkedViewChanged(self.widget.plotItem.vb,v.XAxis)
# syncViews()
# self.widget.plotItem.vb.sigResized.connect(syncViews)
# self._views = views