1

I need to embed a pyplot into a Pyform. Came across the ControlMatplotlib control but have struggled to get it to work. I am not sure what to set the value to.

class SimpleExample(BaseWidget):
    def __init__(self):
        super(SimpleExample, self).__init__('Simple example')


        self._graph = ControlMatplotlib("plot")
        self.formset = [' ', (' ', '_graph', ' '), ' ']

        X = [i for i in range(0,100,2)]
        Y = [i for i in range(0,150,3)]


        pplot.scatter(X, Y)

        self._graph.value = ??
        self._graph.draw() 

Any insight is greatly appreciated.

1 Answer 1

1
class SimpleExample(BaseWidget):
    def __init__(self):
        super().__init__('Simple example')
        self._scatter_plot = ControlMatplotlib()
        self._scatter_plot.value = plot_data


def plot_data(figure):
    axes = figure.add_subplot(111)
    X = [i for i in range(0, 100, 2)]
    Y = [i for i in range(0, 150, 3)]
    axes.scatter(X, Y)


if __name__ == '__main__':
    start_app(SimpleExample)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.