随着使用 chaco 创建简单的条形图,会发生奇怪的行为:一半的图用 line_color 填充,另一个用 fill_color 填充,最后一个根本没有绘制(查看屏幕截图)。预计 x 的 0 到 7000 和 y 的 0 到 150 的数据应该显示并用 line_color 填充。使用小的值可以正常工作(例如,对于 y 值使用 50 而不是 150)。对这种行为有解释吗?如何解决?
下面的代码演示了这个问题:
from enable.api import ComponentEditor
from traits.api import Instance, HasStrictTraits
from traitsui.api import View, UItem
from chaco.api import Plot, ArrayPlotData
class TestPlot(HasStrictTraits):
plot = Instance(Plot)
traits_view = View(UItem('plot', editor=ComponentEditor()),
width=1000, height=800, resizable=True,)
def __init__(self, **kw):
super(TestPlot, self).__init__(**kw)
plot_data = ArrayPlotData(x=list(xrange(0, 7000)), y=[150] * 7000)
self.plot = Plot(plot_data)
self.plot.plot(('x', 'y'), type='bar', line_color="gray", fill_color="lightgray")
self.plot.index_mapper.range.set(low=0 - 150, high=8000 + 50)
self.plot.value_mapper.range.set(low=0 - 50, high=100 + 100)
test = TestPlot()
if __name__ == "__main__":
test.configure_traits()