Professional Documents
Culture Documents
Fator
Fator
Fator
class SenoideApp:
def __init__(self, root):
self.root = root
self.root.title("Gráfico de Senoide")
self.amplitude = tk.DoubleVar(value=100.0)
self.frequencia = tk.DoubleVar(value=60.0)
self.tempo = np.arange(0, 0.1, 0.00001)
def criar_grafico_senoide(self):
figura, ax = Figure(figsize=(10, 4), dpi=100), None
if figura:
ax = figura.add_subplot(111)
ax.set_title("Senoide")
ax.set_xlabel("Tempo (s)")
ax.set_ylabel("Amplitude (V)")
ax.grid(True) # Adiciona as grades ao gráfico
return figura, ax
def plotar_senoide(self):
senoide = self.amplitude.get() * np.sin(2 * np.pi * self.frequencia.get() *
self.tempo)
self.ax.clear()
self.ax.plot(self.tempo, senoide, label=f"Amplitude =
{self.amplitude.get():.2f} V, Frequência = {self.frequencia.get():.2f} Hz")
self.ax.legend()
self.ax.set_ylim(bottom=-200, top=200) # Fixa o eixo y de -200 a 200
self.ax.grid(True) # Garante que as grades estejam visíveis
self.canvas.draw()
if __name__ == "__main__":
root = tk.Tk()
app = SenoideApp(root)
root.mainloop()