Building on the answer from piwnk:
I added this to the .kv file:
#:import MeshLinePlot kivy.garden.graph.MeshLinePlot <SetGraph>: graph_test : graph_test Graph: id: graph_test plot: MeshLinePlot xlabel:'X' ylabel:'Y' x_ticks_minor:5 x_tics_major:25 y_ticks_major:1 y_grid_label:True x_grid_label:True padding:5 x_grid:True y_grid:True xmin:-0 xmax:100 ymin:-1 ymax:1 pos: 0, root.height / 6 size: root.width * 2 / 3 , root.height * 18 / 24
In main.py, I added:
from math import sin from kivy.garden.graph import Graph, MeshLinePlot class SetGraph(Widget): graph_test = ObjectProperty(None) update_graph(self): plot = MeshLinePlot(color=[1, 0, 0, 1]) plot.points = [(x, sin(x / 10.)) for x in range(0, 101)] self.graph_test.add_plot(plot) class graphLayoutApp(App): def build(self): disp = SetGraph() disp.update_graph() return disp if __name__ == '__main__': graphLayoutApp().run()
I changed my original proven solution to more descriptive names. I hope I made no mistakes. Let me know if the solution is not complete.
Mattis asp
source share