내 GUI의 플롯 영역에 데이터를 자동으로 플롯하는 알고리즘이 있습니다. 그렇게하는 데 사용하는 코드가 있습니다.
self.figure = Figure(figsize=(5,4), dpi=100)
self.graph = self.figure.add_subplot(111)
self.canvas = FigureCanvasTkAgg(self.figure, master=self.root)
self.canvas.show()
self.canvas.get_tk_widget().pack(side=LEFT, fill=BOTH, expand=1)
self.canvas._tkcanvas.pack(fill=BOTH, expand=1)
그리고 다음은 플롯 영역에 관련 포인트를 표시하는 방법입니다.
if eigenvalue > self.eigenvalueThreshold:
if self.previousEigenvalue <= self.eigenvalueThreshold:
main.graph.scatter(windowNumber, eigenvalue, c="red")
else:
main.graph.scatter(windowNumber, eigenvalue, c="yellow")
else:
main.graph.scatter(windowNumber, eigenvalue, c="blue")
self.previousEigenvalue = eigenvalue
main.canvas.show()
다음과 같이 데이터 포인트 집합의 가중치에 따라 확대 / 축소가 자동으로 수행됩니다.
다음과 같이 데이터를 그릴 기회가 있는지 알고 싶습니다.
당신은 어떤 생각이 있습니까?
당신이 원하는하는지 들어, 사용하기 쉽다 fill_between
보다는 fill
. 당신이 사용하는 경우 fill
, 당신은 다각형을 만들 verticies을 추가하는 방법에 대해 걱정해야합니다. fill_between
데이터와 상수 값 (기본적으로 0) 또는 다른 곡선 사이의 영역을 자동으로 채 웁니다.
예를 들면 :
import matplotlib.pyplot as plt
import numpy as np
# Generate some data to plot...
x = np.arange(1000)
y = np.random.normal(0, 1, y.size).cumsum()
y[y < 0] *= -1
fig, ax = plt.subplots()
# Fill the region between your curve and 0 with red...
ax.fill_between(x, y, facecolor='red', edgecolor='none')
# Optional...
ax.grid(True, color='white', linewidth=2, linestyle='-')
ax.set(axisbelow=True, axis_bgcolor='lightgray')
ax.tick_params(direction='out')
plt.show()
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다