====== Kivy: Exemples de Kivy Garden Graph ====== **{{tagpage>kivy|Toutes les pages Kivy}}** **[[http://translate.google.com/translate?hl=&sl=auto&tl=en&u=https%3A%2F%2Fressources.labomedia.org%2Fkivy_graph_examples|English Version]]** **[[les_pages_kivy_en_details|Les pages Kivy en détails]]** Retour à **[[kivy_garden|Kivy Garden]]** =====Ressources===== * Cet exemple est instiré de **[[https://github.com/kivy/plyer/tree/master/examples/accelerometer/using_graph|accelerometer using graph]]** qui est un exemple de [[https://github.com/kivy/plyer|]] * **[[kivy_plyer|La page du wiki sur plyer]]** * **[[https://github.com/kivy-garden/graph|https://github.com/kivy-garden/graph]]** * **[[https://kivy-garden.github.io/graph/flower.html|Docs » The Graph API » Graph]]** Les exemples sont disponible dans le projet Smart Citizen: https://github.com/sergeLabo/smartcitizen/tree/master/smartcitizen/garden_graph_example =====Exemple très simple===== Pour expliquer, inutile d'introduire les Nombres Complexes (y = a + b*i) avec i*i = -1 ou les arctg(ln(0.154236987))! {{ media_06:graphexample_1.png?500 |}} #! /usr/bin/env python3 # -*- coding: utf-8 -*- """ Inspiré de: https://github.com/kivy/plyer/tree/master/examples/accelerometer/using_graph """ from math import sin import kivy kivy.require('1.11.1') from kivy.app import App from kivy.properties import ObjectProperty from kivy.uix.boxlayout import BoxLayout from kivy_garden.graph import Graph, MeshLinePlot class GraphExample(BoxLayout): graph = ObjectProperty() def __init__(self, **kwargs): super().__init__(**kwargs) plot = MeshLinePlot(color=[1, 0, 0, 1]) plot.points = [(x, sin(x / 10.)) for x in range(0, 101)] # Recherche des widgets print([type(widget) for widget in self.walk(loopback=True)]) # Appel du widget avec l'id graph self.ids.graph.add_plot(plot) class GraphExampleApp(App): def build(self): return GraphExample() if __name__ == '__main__': GraphExampleApp().run() #:kivy 1.11.1 : BoxLayout: orientation: 'vertical' padding: 20 Graph: size_hint_y: 0.8 id: graph background_color: 0, 1, 1, 1 border_color: 1, 1, 0, 1 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 =====Le même exemple avec la sinusoïde qui glisse===== * **[[https://github.com/sergeLabo/smartcitizen/tree/master/smartcitizen/garden_graph_example/graph_2|graph_2]]** {{tag> kivy python sb }}