I was successful on embedding a matpotlib bar graph onto tkinter, however I can seem to find a way to disply text underneat each bar. The desired result would be text displaying the content of each bar underneath, for example
bar 1, bar 2, bar 3, bar 4, bar 5, any help would be greatly apperciated.
Happy holidays to all the programming community! -
#!/usr/bin/env python
-
import matplotlib
-
matplotlib.use('TkAgg')
-
import numpy as np
-
import matplotlib.pyplot as plt
-
from numpy import arange, sin, pi
-
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
-
from matplotlib.figure import Figure
-
from Tkinter import Tk, Frame, Menu
-
import sys
-
if sys.version_info[0] < 3:
-
import Tkinter as Tk
-
else:
-
import tkinter as Tk
-
-
def sabina():
-
print "Sabina"
-
-
def saoPaulo():
-
print "Sao Paulo"
-
-
def NSMX():
-
print "NSMX"
-
def knob():
-
print "KNOB"
-
def pointer():
-
print "POINTER"
-
def ambient():
-
print "AMBIENT"
-
-
class Example(Frame):
-
-
def __init__(self, parent):
-
Frame.__init__(self, parent)
-
-
self.parent = parent
-
-
self.initUI()
-
-
def initUI(self):
-
-
self.parent.title("Submenu")
-
-
menubar = Menu(self.parent)
-
self.parent.config(menu=menubar)
-
-
customers = Menu(menubar)
-
customers.add_command(label='Sabina', underline=0, command=sabina)
-
customers.add_command(label='Sao Paulo', underline=0, command=saoPaulo)
-
customers.add_command(label='NSMX', underline=0, command=NSMX)
-
customers.add('separator')
-
customers.add_command(label="Exit", underline=0, command=self.onExit)
-
-
-
-
menuProducts = Menu(menubar)
-
menuProducts.add_command(label='Knob', underline=0, command=knob)
-
menuProducts.add_command(label='Pointer', underline=0, command=pointer)
-
menuProducts.add_command(label='Ambient', underline=0, command=ambient)
-
menuProducts.add('separator')
-
menuProducts.add_command(label="Exit", underline=0, command=self.onExit)
-
-
menuMaq = Menu(menubar)
-
menuMaq.add_command(label='Sabina', underline=0, command=sabina)
-
menuMaq.add_command(label='Sao Paulo', underline=0, command=saoPaulo)
-
menuMaq.add_command(label='NSMX', underline=0, command=NSMX)
-
menuMaq.add('separator')
-
menuMaq.add_command(label="Exit", underline=0, command=self.onExit)
-
-
menubar.add_cascade(label="Customers", underline=0, menu=customers)
-
menubar.add_cascade(label="Products", underline=0, menu=menuProducts)
-
-
def onExit(self):
-
self.quit()
-
-
-
def destroy(e): sys.exit()
-
-
root = Tk.Tk()
-
root.wm_title("Produccion Status")
-
#root.bind("<Destroy>", destroy)
-
prodName='Model name'
-
pO=19000
-
po=[19000,19000,19000,19000,19000]
-
N = ['Cap', 'bush', 'pointer', 'omori', 'KanseiHin']
-
existencias = [10000, 2000, 1100, 3500,3000]
-
retrasos = [int(pO-existencias[0]),int(pO-existencias[1]),\
-
int(pO-existencias[2]),int(pO-existencias[3]),int(pO-existencias[4])]#[5000, 8200, 9400, 2000]
-
ind = np.arange(len(N)) # the x locations for the groups
-
width = .80 # the width of the bars: can also be len(x) sequence
-
-
f = Figure(figsize=(3,3), dpi=150)#window size
-
a = f.add_subplot(111)#layout
-
#t = arange(00,10,001)#xticks
-
#s = sin(2*pi*t)
-
a.bar(ind, po, width, color='r')
-
a.bar(ind, existencias, width, color='y')
-
#a.bar(ind, retrasos, width, color='r')
-
a.set_title(prodName)
-
#ylabel('Cantidades')
-
#title('Nombre del Modelo')
-
a.set_xticks(ind+width/2., ('Cap', 'bush', 'pointer', 'omori', 'KanseiHin') )
-
a.set_yticks(np.arange(0,20000,1000))
-
a.set_xlabel('buhin')
-
a.set_ylabel('Cantidades')
-
-
-
# a tk.DrawingArea
-
canvas = FigureCanvasTkAgg(f, master=root)
-
canvas.show()
-
#canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
-
-
#toolbar = NavigationToolbar2TkAgg( canvas, root )
-
#toolbar.update()
-
canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
-
-
button = Tk.Button(master=root, text='Quit', command=sys.exit)
-
button.pack(side=Tk.BOTTOM)
-
app = Example(root)
-
app1 = Example(root)
-
Tk.mainloop()
-
0 1370 Sign in to post your reply or Sign up for a free account.
Similar topics
by: WOJSAL |
last post by:
I want show HTML-text (messages, textarea etc.)
with TkInter. What free package, module i need?
Please help.
--
Regards
|
by: John B. |
last post by:
I'm using <h1>MY HEADING</h1> to display a title, however I would like to
show one short line of text beside it<p>The short line of text</p>, and then
go back to normal.
Here's an example of how...
|
by: William Gill |
last post by:
Is there a simple way to cut and paste from a tkinter text widget to an
entry widget? I know I could create a mouse button event that triggers
a popup (message widget) prompting for cut/paste in...
|
by: Susan Bricker |
last post by:
Greetings.
I am having trouble populating text data that represents data in my
table. Here's the setup:
There is a People Table (name, address, phone, ...)
peopleID = autonumber key
There...
|
by: Ron Vecchi |
last post by:
I have a text file(.js) that holds a buch of java script code that is
rendered in some web controls all part of a larger webcontrol library.
The file is rather large. Would embedding this...
|
by: doctorle |
last post by:
I use Access XP (2002) and have had no problem designing forms, reports
and displaying data in Unicode (Vietnamese). But Unicode strings fail
to display properly inside charts (MS Graph 8 object)....
|
by: sj |
last post by:
I am just learning to use Tkinter and am having problems displaying image
files. I am able to display an image using tutorials (such as
http://www.daniweb.com/code/snippet296.html) But when I try...
|
by: paragguptaiiita |
last post by:
I have one problem regarding displaying text from XML file.
I have a XSL variable named $p = (0 0 0) (0.82 0 0) (1.63 -0.01 0) (2.63 -0.01 0) (3.63 -0.01 0) (4.63 -0.01 0) (5.63 -0.02 0) (6.63 -0.02...
|
by: paragguptaiiita |
last post by:
I have one problem regarding displaying text from XML file.
I have a XSL variable named $p = (0 0 0) (0.82 0 0) (1.63 -0.01 0) (2.63 -0.01 0) (3.63 -0.01 0) (4.63 -0.01 0) (5.63 -0.02 0) (6.63 -0.02...
|
by: littlealex |
last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS!
In IE6 the text for the following page doesn't display properly - rather than being...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |