mirror of https://github.com/mpv-player/mpv
TOOLS/stats-conv: rewrite for pygtgraph
matplotlib is pathetically slow, which makes using stats-conv.py to view dumps longer than a few seconds a huge pain. pyqtgraph is slightly faster than matplotlib. Other than that, it seems to be worse in every aspect (at least for plotting), but such is life.
This commit is contained in:
parent
3a7a2385df
commit
2483dab54d
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import matplotlib.pyplot as plot
|
from pyqtgraph.Qt import QtGui, QtCore
|
||||||
|
import pyqtgraph as pg
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
@ -38,8 +39,8 @@ Currently, the following event types are supported:
|
||||||
class G:
|
class G:
|
||||||
events = {}
|
events = {}
|
||||||
start = None
|
start = None
|
||||||
# http://matplotlib.org/api/markers_api.html#module-matplotlib.markers
|
markers = ["o", "s", "t", "d"]
|
||||||
markers = ["o", "8", "s", "p", "*", "h", "+", "x", "D"]
|
curveno = 0
|
||||||
|
|
||||||
def find_marker():
|
def find_marker():
|
||||||
if len(G.markers) == 0:
|
if len(G.markers) == 0:
|
||||||
|
@ -128,20 +129,31 @@ for e, index in zip(G.sevents, range(len(G.sevents))):
|
||||||
else:
|
else:
|
||||||
e.vals = [(x, y * (m - index) / m) for (x, y) in e.vals]
|
e.vals = [(x, y * (m - index) / m) for (x, y) in e.vals]
|
||||||
|
|
||||||
fig = plot.figure()
|
pg.setConfigOption('background', 'w')
|
||||||
fig.hold(True)
|
pg.setConfigOption('foreground', 'k')
|
||||||
|
app = QtGui.QApplication([])
|
||||||
|
win = pg.GraphicsWindow()
|
||||||
|
#win.resize(1500, 900)
|
||||||
|
|
||||||
ax = [None, None]
|
ax = [None, None]
|
||||||
plots = 2 if hasval else 1
|
plots = 2 if hasval else 1
|
||||||
ax[0] = fig.add_subplot(plots, 1, 1)
|
ax[0] = win.addPlot()
|
||||||
if hasval:
|
if hasval:
|
||||||
ax[1] = fig.add_subplot(plots, 1, 2, sharex=ax[0])
|
win.nextRow()
|
||||||
legends = [[], []]
|
ax[1] = win.addPlot()
|
||||||
for e in G.sevents:
|
ax[1].setXLink(ax[0])
|
||||||
cur = ax[1 if e.type == "value" else 0]
|
|
||||||
pl, = cur.plot([x for x,y in e.vals], [y for x,y in e.vals], label=e.name)
|
|
||||||
if e.type == "event-signal":
|
|
||||||
plot.setp(pl, marker = e.marker, linestyle = "None")
|
|
||||||
for cur in ax:
|
for cur in ax:
|
||||||
if cur is not None:
|
if cur is not None:
|
||||||
cur.legend()
|
cur.addLegend(offset = (-1, 1))
|
||||||
plot.show()
|
for e in G.sevents:
|
||||||
|
cur = ax[1 if e.type == "value" else 0]
|
||||||
|
args = {'name': e.name,'antialias':True}
|
||||||
|
if e.type == "event-signal":
|
||||||
|
args['symbol'] = e.marker
|
||||||
|
args['pen'] = None
|
||||||
|
else:
|
||||||
|
args['pen'] = pg.mkPen(pg.intColor(G.curveno), width=0)
|
||||||
|
G.curveno += 1
|
||||||
|
n = cur.plot([x for x,y in e.vals], [y for x,y in e.vals], **args)
|
||||||
|
|
||||||
|
QtGui.QApplication.instance().exec_()
|
||||||
|
|
Loading…
Reference in New Issue