tkinter 창에서 Windrose를 플로팅하는 데 문제가 있습니다. 윈드 로즈가 단독으로 표시되도록 할 수 없습니다. 창에는 플롯 뒤에 또 다른 그리드가 표시됩니다 (아래 그림 참조). 배경에 여분의 그리드가없는 바람 장미 만 표시 할 수있는 방법이 있습니까? 최종 코드는 x 초마다 업데이트되므로 플롯이 애니메이션됩니다.
from tkinter import *
from windrose import WindroseAxes
from matplotlib import pyplot as plt
import numpy as np
import matplotlib
matplotlib.use("TkAgg")
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import matplotlib.animation as animation
from matplotlib import style
import tkinter as tk
root = Tk()
style.use("ggplot")
fig = plt.figure(figsize=(6,4),dpi=100)
a = fig.add_subplot(111)
def animate(i):
ws = np.random.random(500) * 6
wd = np.random.random(500) * 360
a.clear()
rect = [0.1,0.1,0.8,0.8]
wa = WindroseAxes(fig, rect)
fig.add_axes(wa)
wa.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')
wa.set_legend()
canvas = FigureCanvasTkAgg(fig,root)
canvas.show()
canvas.get_tk_widget().pack(side=tk.BOTTOM,fill=tk.BOTH,
expand=True,anchor='s')
ani = animation.FuncAnimation(fig, animate, interval=1000)
root.mainloop()
서로 위에 두 개의 플롯을 플로팅합니다.
from tkinter import *
from windrose import WindroseAxes
from matplotlib import pyplot as plt
import numpy as np
import matplotlib
matplotlib.use("TkAgg")
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import matplotlib.animation as animation
from matplotlib import style
import tkinter as tk
root = Tk()
style.use("ggplot")
fig = plt.figure(figsize=(6,4),dpi=100)
#a = fig.add_subplot(111) # this gives you the square grid in the background
def animate(i):
ws = np.random.random(500) * 6
wd = np.random.random(500) * 360
# a.clear() # not needed if plot doesn't exist
fig.clear() # we need to clear the figure you're actually plotting to
rect = [0.1,0.1,0.8,0.8]
wa = WindroseAxes(fig, rect)
fig.add_axes(wa)
wa.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')
wa.set_legend()
canvas = FigureCanvasTkAgg(fig,root)
canvas.show()
canvas.get_tk_widget().pack(side=tk.BOTTOM,fill=tk.BOTH,
expand=True,anchor='s')
ani = animation.FuncAnimation(fig, animate, interval=1000)
root.mainloop()
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다