使用下面的最小示例,我得到的一个大型(大约110k点)图的折线图(使用python 2.7,numpy 1.5.1,chaco / enable / traits 4.3.0)是:
但是,这很奇怪,因为它是一个线图,并且那里不应该有任何填充区域?特别是由于数据是锯齿状信号?好像在y〜= 37XX处有一行,上面有颜色填充吗?但是可以肯定的是,如果我放大一个区域,则可以得到期望的渲染-没有意外的填充:
这是一个错误-还是我做错了什么?我尝试使用use_downsampling
,但这没什么关系...
测试代码:
import numpy as np
import numpy.random as npr
from pprint import pprint
from traits.api import HasTraits, Instance
from chaco.api import Plot, ArrayPlotData, VPlotContainer
from traitsui.api import View, Item
from enable.component_editor import ComponentEditor
from chaco.tools.api import PanTool, BetterSelectingZoom
tlen = 112607
alr = npr.randint(0, 4000, tlen)
tx = np.arange(0.0, 30.0-0.00001, 30.0/tlen)
ty = np.arange(0, tlen, 1) % 10000 + alr
pprint(len(ty))
class ChacoTest(HasTraits):
container = Instance(VPlotContainer)
traits_view = View(
Item('container', editor=ComponentEditor(), show_label=False),
width=800, height=500, resizable=True,
title="Chaco Test"
)
def __init__(self):
super(ChacoTest, self).__init__()
pprint(ty)
self.plotdata = ArrayPlotData(x = tx, y = ty)
self.plotobj = Plot(self.plotdata)
self.plotA = self.plotobj.plot(("x", "y"), type="line", color=(0,0.99,0), spacing=0, padding=0, alpha=0.7, use_downsampling=True)
self.container = VPlotContainer(self.plotobj, spacing=5, padding=5, bgcolor="lightgray")
#~ container.add(plot)
self.plotobj.tools.append(PanTool(self.plotobj))
self.plotobj.overlays.append(BetterSelectingZoom(self.plotobj))
if __name__ == "__main__":
ChacoTest().configure_traits()
我能够重现该错误并与John Wiggins(Enable的维护者)交谈,这是kiva中的一个错误(chaco用来在屏幕上绘画):https : //github.com/enthought/enable好消息是这是您可以使用的kiva后端之一中的错误。因此,要解决此问题,您可以选择其他后端来运行脚本:
ETS_TOOLKIT=qt4.qpainter python <NAME OF YOUR SCRIPT>
如果使用qpainter或quartz,则该图看起来(在我的计算机上)符合预期。如果选择qt4.image(Agg后端),则将重现该问题。不幸的是,Agg后端是默认后端。要更改此设置,可以将ETS_TOOLKIT环境变量设置为该值:
export ETS_TOOLKIT=qt4.qpainter
坏消息是解决这个问题将不是一件容易的事。如果您想参与其中,请随时报告github中的错误(再次https://github.com/enthought/enable)。如果没有,我会在接下来的几天内记录下来。感谢您举报!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句