我正试图将我的轴线照相,但我没有使用<代码>plt.yps([])。 该方案正在向我展示价值观。 你们能否帮助我ed,请? 也许问题在于,我正在使用“血管”,我试图将<条码>(......)条码>放到他中间,但甚至没有工作。
Below my code:
import tkinter as tk
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib import animation
import random
# Create the Tkinter window
root = tk.Tk()
root.geometry( 400x100 )
fig1, b1 = plt.subplots(figsize=(10, 0.5), dpi = 80,)
b1 = fig1.add_subplot(111)
fig2, b2 = plt.subplots(figsize= (10, 0.5), dpi = 80)
b2 = fig2.add_subplot(111)
def grafico_1 (i):
global b1
global nume
global valu
global fig1
global y_fix
global x
x = []
y_fix = []
ws = [ WIRE ]
for valu in range (1, 6):
nume = random.randint(1, 10)
x.append(nume)
#print(x)
#Primeira camada do grafico
if int(x[0]) < 3:
y_fix.append(int(x[0]), )
#print(f Lista de y_n ,e {y_n} )
b1.barh(ws, int(x[0]), color = green )
if int(x[0]) >= 3 and int(x[0]) < 6:
y_fix.append(x[0])
b1.barh(ws, int(x[0]), color = yellow )
if int(x[0]) >= 6:
y_fix.append(x[0])
b1.barh(ws, int(x[0]), color= red )
#Segunda camada:
for c in x[1:]:
if int(c) < 3 :
b1.barh(ws, int(c), color= green , left=y_fix)
y_fix.append(int(c))
jump = sum(y_fix)
y_fix = []
y_fix.append(jump)
if int(c) > 3 and int(c) < 5:
b1.barh(ws, int(c), color= yellow , left= y_fix)
y_fix.append(int(c))
jump = sum(y_fix)
y_fix = []
y_fix.append(jump)
if int(c) >= 5:
b1.barh(ws, int(c), color= red , left= y_fix)
y_fix.append(int(c))
jump = sum(y_fix)
y_fix = []
y_fix.append(jump)
def grafico_2 (i2):
global b2
global nume2
global valu2
global fig2
global y_fix2
global x2
x2 = []
y_fix2 = []
ws2 = [ line 2 ]
for valu2 in range (1, 6):
nume2 = random.randint(1, 10)
x2.append(nume2)
#print(f Grafico 2 {x2} )
#Primeira camada do grafico
if int(x2[0]) < 3:
y_fix2.append(int(x2[0]))
#print(f Lista de y_n ,e {y_n} )
b2.barh(ws2, int(x2[0]), color = green )
if int(x2[0]) >= 3 and int(x2[0]) < 6:
y_fix2.append(x2[0])
b2.barh(ws2, int(x2[0]), color = yellow )
if int(x2[0]) >= 6:
y_fix2.append(x2[0])
b2.barh(ws2, int(x2[0]), color= red )
#Segunda camada:
for c2 in x2[1:]:
if int(c2) < 3 :
b2.barh(ws2, int(c2), color= green , left=y_fix2)
y_fix2.append(int(c2))
jump2 = sum(y_fix2)
y_fix2 = []
y_fix2.append(jump2)
if int(c2) > 3 and int(c2) < 5:
b2.barh(ws2, int(c2), color= yellow , left= y_fix2)
y_fix2.append(int(c2))
jump2 = sum(y_fix2)
y_fix2 = []
y_fix2.append(jump2)
if int(c2) >= 5:
b2.barh(ws2, int(c2), color= red , left= y_fix2)
y_fix2.append(int(c2))
jump2 = sum(y_fix2)
y_fix2 = []
y_fix2.append(jump2)
#plt.show()
ani1 = animation.FuncAnimation(fig1, grafico_1, interval = 3000, frames=100)
ani2 = animation.FuncAnimation(fig2, grafico_2, interval = 3000, frames=100)
# Embed the figures into Tkinter using FigureCanvasTkAgg
canvas1 = FigureCanvasTkAgg(fig1, master=root)
canvas1.get_tk_widget().place(x= 300, y= 460)
canvas2 = FigureCanvasTkAgg(fig2, master=root)
canvas2.get_tk_widget().place(x= 300, y = 530)
root.mainloop()
1. 在轴心中创造无任何数字的图形