Python:仅接受1个参数(给定0个)错误
我创建了一个名为create_plot的方法来传递x,y1,x_axis_name,y_axis_name的值来创建Python chaco图Python:仅接受1个参数(给定0个)错误,python,chaco,Python,Chaco,我创建了一个名为create_plot的方法来传递x,y1,x_axis_name,y_axis_name的值来创建Python chaco图 def create_plot(self, x, y1, x_axis_name, y_axis_name): self.x = x self.y1 = y1 self.x_axis_name = x_axis_name self.y_axis_name = y_ax
def create_plot(self, x, y1, x_axis_name, y_axis_name):
self.x = x
self.y1 = y1
self.x_axis_name = x_axis_name
self.y_axis_name = y_axis_name
plotdata = ArrayPlotData(x, y1)
plot = Plot(plotdata)
plot.x_axis.title = x_axis_name #String Example "(s)"
plot.y_axis.title = y_axis_name #String Example "(m)"
renderer = plot.plot(("x", "y1"), type="line", color="blue",
width=2.0)[0]
renderer.overlays.append(LineInspector(renderer,
axis='value',write_metadata=True, is_listener=True))
plot.overlays.append(ZoomTool(plot, tool_mode="range"))
plot.tools.append(PanTool(plot))
container = HPlotContainer(background="lightgray")
container.add(plot)
return container
def _create_plot_component(self):
self.wind_speed_graph = self.create_plot(time_list,
data_list, "(s)", "(m)")
wind_speed_graph = Instance(Component)
def _wind_speed_graph_default(self):
return _create_plot_component()
当我编译时,会出现以下错误“\u create\u plot\u component()正好接受1个参数(给定0)”。“创建图”是我创建的正确方法吗?如何修复此错误 您需要使用类实例调用此方法,因为它是(非静态)类方法 解决方案与此类似。我不能确定,因为有相当数量的代码似乎丢失了
def _wind_speed_graph_default(self):
# note the my_instance
return my_instance._create_plot_component()
self.\u create\u plot\u component()
它显示相同的错误它不会显示相同的错误,我向您保证def\u wind\u speed\u graph\u default(self):在另一个类中。它显示了相同的错误。如果它是在另一个类中定义的,为什么要取消它的self
,而不是该类的实例?