PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, June 28, 2022

[FIXED] How to create real time graph in kivy?

 June 28, 2022     graph, kivy, python-2.7     No comments   

Issue

I want to create a real time graph in kivy. How can i achieve that? I m new to kivy. Please help me.


Solution

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.



Answered By - user5892612
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing