I want to create a real time graph in kivy. How can i achieve that? I m new to kivy. Please help me.
Adding matplotlib to a kivy app is pretty easy, we'll use kivy_garden and it'll be a piece of cake!
KivyMD is a collection of Material Design widgets for use with Kivy, a GUI framework for making mobile applications. It is similar to the Kivy framework but provides a more attractive GUI.
Kivy is a graphical user interface opensource Python library that allows you to develop multi-platform applications on Windows, macOS, Android, iOS, Linux, and Raspberry-Pi. In addition to the regular mouse and keyboard inputs, it also supports multitouch events.
define your plot
e.g.
plot = MeshLinePlot(color=next(colors))
define graph
e.g.
graph = Graph(
xlabel='Iteration',
ylabel='Value',
x_ticks_minor=1,
x_ticks_major=5,
y_ticks_major=1,
y_grid_label=True,
x_grid_label=True,
padding=5,
xlog=False,
ylog=False,
x_grid=True,
y_grid=True,
ymin=0,
ymax=11,
**graph_theme)
update graph and update x axis:
e.g.
def update_xaxis(self,*args):
global graph
global cnt
graph.xmin = cnt - 50
graph.xmax = cnt
def update_points(self, *args):
global i
global MYLIST
global cnt
#self.plot.points = [(i,i)]
self.plot.points = [z for z in MYLIST]
call a Clock
e.g.
Clock.schedule_interval(self.update_points, 1/60.)
Clock.schedule_interval(self.update_xaxis, 1/60.)
and add the widget:
b.add_widget(graph)
I hope I have not forgotten anything. It gives you running graph with kivy Garden.
There is a graph widget in the kivy garden. You can read about using garden widgets in kivy's documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With