我用这个类来画一个跟踪,我有两条线要跟踪,但我不能显示每一条线的名称,如何?你知道吗
class Plot2D():
def __init__(self):
self.traces = dict()
#QtGui.QApplication.setGraphicsSystem('raster')
self.app = QtGui.QApplication([])
#mw = QtGui.QMainWindow()
#mw.resize(800,800)
self.win = pg.GraphicsWindow(title="Detecting cluck")
self.win.resize(1000,600)
self.win.setWindowTitle('Detecting')
# Enable antialiasing for prettier plots
pg.setConfigOptions(antialias=True)
self.canvas = self.win.addPlot(title="改装车检测")
self.canvas.setYRange(0, 1)
def start(self):
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()
def trace(self,name,dataset_x,dataset_y,sColor):
if name in self.traces:
self.traces[name].setData(dataset_x,dataset_y)
else:
self.traces[name] = self.canvas.plot(
pen=pg.mkPen(sColor, width=3), name="car")
我得到的是:
我得到了什么
我想要的是:
除了在绘图中建立名称外,还必须使用
addLegend()
:更新:
如果要更改字体大小,可以使用HTML
相关问题 更多 >
编程相关推荐