Can't see anything while running simple graph of kivy garden??

528 views
Skip to first unread message

Shruti Chandra

unread,
Jul 1, 2015, 5:17:15 AM7/1/15
to kivy-...@googlegroups.com

I am not able to see the graph! Can anyone help me telling the problem ?? I just started using graphs in kivy!





from
kivy.garden.graph import Graph, MeshLinePlot
import math

graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5, x_ticks_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) plot = MeshLinePlot(color=[1, 0, 0, 1]) plot.points = [(x, math.sin(x / 10.)) for x in range(0, 101)] graph.add_plot(plot)

Alexander Taylor

unread,
Jul 1, 2015, 6:37:02 AM7/1/15
to kivy-...@googlegroups.com, shrutich...@gmail.com
Post a full, working example.

Shruti Chandra

unread,
Jul 1, 2015, 7:30:14 AM7/1/15
to kivy-...@googlegroups.com
Here is my full code.   Actually, I am trying to read a file having x, y positions and want to plot those positions on canvas.  Here I am trying to use graphs from kivy. I already did this with matplot.




from kivy.app import App
from kivy.uix.widget import Widget

from kivy.garden.graph import Graph, MeshLinePlot
import math


class MistakeCorrect(Widget):
   
    def __init__(self, **kwargs):
        super(MistakeCorrect, self).__init__(**kwargs)
       
       
    def draw(self):
            graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5,x_ticks_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)
            plot = MeshLinePlot(color=[1, 0, 0, 1])
            plot.points = [(x, math.sin(x / 10.)) for x in range(0, 101)]
            graph.add_plot(plot)


class MistakeApp(App):
   
        
    def build(self):
        mis =  MistakeCorrect()       
        mis.draw()
        return mis
       
      
if __name__ == '__main__':
    MistakeApp().run()       
           

.kv file



#:kivy 1.9.0

<MistakeCorrect>:
  
    #canvas:
    #    Color:
    #        rgba: 1, 1, 1, .7
    #    Rectangle:          
    #        pos: self.center_x / 8  , self.center_y / 2
    #        size: 370, 370
   
    Slider:
        orientation: 'horizontal'
        pos: 460, 300
        width: 250               
        id: param
        min: 0
        max: 50
        value: 25
        step: 1
       
    Button:
        text: 'False!'
        pos: 500, 50
        size: 75, 75       
        background_color:1,0, 0,1
       
    Button:
        text: 'True!'
        pos: 650, 50
        size: 75, 75          
        background_color:0,1, 0,1

       


    









On Wednesday, 1 July 2015 11:37:02 UTC+1, Alexander Taylor wrote:
Post a full, working example.

On Wednesday, 1 July 2015 10:17:15 UTC+1, Shruti Chandra wrote:

On Wednesday, 1 July 2015 10:17:15 UTC+1, Shruti Chandra wrote:

Alexander Taylor

unread,
Jul 1, 2015, 7:32:11 AM7/1/15
to kivy-...@googlegroups.com
You never add the graph to anything. Try 'self.add_widget(graph)' at the
bottom of the draw method.

This won't give it the size and position you want, but should make it
appear.
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Kivy users support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/kivy-users/kZUwkieHCHw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> kivy-users+...@googlegroups.com
> <mailto:kivy-users+...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.


signature.asc

Shruti Chandra

unread,
Jul 1, 2015, 7:34:47 AM7/1/15
to kivy-...@googlegroups.com
Thankyou :D

cheers,
Shruti Chandra


To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.

sulabh tiwari

unread,
Jul 1, 2015, 3:40:09 PM7/1/15
to kivy-...@googlegroups.com
Hi Shruti,

Just wanted to know if you managed to show graph. Moreover are you able to locate position and size of it.

-Sulabh
Thankyou :D

cheers,
Shruti Chandra


Reply all
Reply to author
Forward
0 new messages