Skip to content

Please add this example: How to use in kv file #65

Open
@escallonia

Description

This example shows how to extend FigureCanvasKivyAgg for use in a kv file.

extend4kv.py:

#!/usr/bin/env python3                                                                
from kivy.garden.matplotlib.backend_kivyagg import FigureCanvasKivyAgg                
from kivy.app import App                                                              
import matplotlib.pyplot as plt                                                                                                                                             

plt.plot([1, 23, 2, 4])                                                               
plt.ylabel('some numbers')                                                                                                                                                  

# A class in which __init__ has no positional parameters, so it can be used in a kv file:
class MyFigure(FigureCanvasKivyAgg):                                                      
    def __init__(self, **kwargs): 
        super().__init__(plt.gcf(), **kwargs)    

class Extend4Kv(App):
    pass

Extend4Kv().run()

Now use in the file extend4kv.kv:

# kv file
MyFigure:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions