pythonchaco

Python: takes exactly 1 argument (0 given) Error


I created a method called create_plot to pass the x, y1, x_axis_name, y_axis_name values to create a Python chaco graph.

    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()

When I compile I get this error "_create_plot_component() takes exactly 1 argument (0 given)". is "create_plot" right method I created? how can I fix this error?


Solution

  • You need to call this method with a class instance as it is a (non-static) class method.

    Solution would be something similar to this. I can't tell for certain, because a fair amount of code seems to be missing.

    def _wind_speed_graph_default(self):
        # note the my_instance
        return my_instance._create_plot_component()