import matplotlib
matplotlib.use('module://kivy.garden.matplotlib.backend_kivy')
from matplotlib.figure import Figure
from numpy import arange, sin, pi
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import NumericProperty, ReferenceListProperty,\
ObjectProperty
from kivy.clock import Clock
import numpy as np
#from kivy.garden.matplotlib.backend_kivyagg import FigureCanvas
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.boxlayout import BoxLayout
from matplotlib.transforms import Bbox
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.graphics import Color, Line, Rectangle
import matplotlib.pyplot as plt
class GT(Widget):
N = 5
menMeans = (20, 35, 30, 35, 27)
menStd = (2, 3, 4, 1, 2)
ind = np.arange(N) # the x locations for the groups
# width = 1 # the width of the bars
# width = 0.35 # the width of the bars
fig, ax = plt.subplots()
rects1 = ax.bar(ind, menMeans, 0.3, color='r', yerr=menStd)
# rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd)
womenMeans = (25, 32, 34, 20, 25)
womenStd = (3, 5, 2, 3, 3)
# add some text for labels, title and axes ticks
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind + 0.3)
# ax.set_xticks(ind + width)
ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))
canvas = fig.canvas
fl = BoxLayout(orientation="vertical")
a = Button(text="Run", height=40, size_hint_y=None)
b = Label(text="Feedback goes here", height=100, size_hint_y=0.2)
fl.add_widget(canvas) # Graph drawing area
fl.add_widget(b) # Feedback text area
fl.add_widget(a) # Run button
class MatplotlibTest(App):
title = 'Simpler Matplotlib Test'
def build(self):
gt = GT()
#Clock.schedule_interval(gt.update, 1.0 / 10.0)
return gt
if __name__ == '__main__':
MatplotlibTest().run()