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()
This example shows how to extend FigureCanvasKivyAgg for use in a kv file.
extend4kv.py:
Now use in the file extend4kv.kv: