天花w=10=sh
vispy visual.HistogramVisual
离开 examples/basics/visuals/graphy.py,我尝试显示直方图但失败了:
from vispy import app, visuals
import wx
import numpy as np
class snrHistogram(app.Canvas):
def __init__(self, *args, **kwargs):
app.Canvas.__init__(self, title='histogram fail',
keys="interactive", size=(600, 600))
self.snr_hist = visuals.HistogramVisual(np.arange(256), bins=4, color='r', orientation='v')
self.label = visuals.TextVisual("hi", color='blue', pos=[50, 50, 0])
self.configure_transforms()
self.show()
def configure_transforms(self):
vp = (0, 0, self.physical_size[0], self.physical_size[1])
self.context.set_viewport(*vp)
self.label.transforms.configure(canvas=self, viewport=vp)
self.snr_hist.transforms.configure(canvas=self, viewport=vp)
def on_resize(self, event):
self.configure_transforms()
def on_mouse_wheel(self, event):
self.update()
def on_draw(self, event):
self.snr_hist.draw()
self.label.draw()
self.update()
def on_close(self, event):
self.close()
if __name__ == '__main__':
s = snrHistogram()
app.run()
但文本视觉效果还不错。我理解histogramVisual是mesh的一个子类,但是在mesh.py的源码里没看到有用的东西。我正在使用 wx 作为我的后端。
直方图出现了,但是很小。以下输入数据将强制程序显示直方图:
self.snr_hist = visuals.HistogramVisual(
np.repeat([0, 1, 1, 20, 20, 40, 40, 80, 80, 90, 81, 70, 65],
100), bins=4, color='r', orientation='h')
离开 examples/basics/visuals/graphy.py,我尝试显示直方图但失败了:
from vispy import app, visuals
import wx
import numpy as np
class snrHistogram(app.Canvas):
def __init__(self, *args, **kwargs):
app.Canvas.__init__(self, title='histogram fail',
keys="interactive", size=(600, 600))
self.snr_hist = visuals.HistogramVisual(np.arange(256), bins=4, color='r', orientation='v')
self.label = visuals.TextVisual("hi", color='blue', pos=[50, 50, 0])
self.configure_transforms()
self.show()
def configure_transforms(self):
vp = (0, 0, self.physical_size[0], self.physical_size[1])
self.context.set_viewport(*vp)
self.label.transforms.configure(canvas=self, viewport=vp)
self.snr_hist.transforms.configure(canvas=self, viewport=vp)
def on_resize(self, event):
self.configure_transforms()
def on_mouse_wheel(self, event):
self.update()
def on_draw(self, event):
self.snr_hist.draw()
self.label.draw()
self.update()
def on_close(self, event):
self.close()
if __name__ == '__main__':
s = snrHistogram()
app.run()
但文本视觉效果还不错。我理解histogramVisual是mesh的一个子类,但是在mesh.py的源码里没看到有用的东西。我正在使用 wx 作为我的后端。
直方图出现了,但是很小。以下输入数据将强制程序显示直方图:
self.snr_hist = visuals.HistogramVisual(
np.repeat([0, 1, 1, 20, 20, 40, 40, 80, 80, 90, 81, 70, 65],
100), bins=4, color='r', orientation='h')