aggiunta grafici sia per il single layer che per il multilayer

This commit is contained in:
2025-01-23 17:14:47 +01:00
parent a267d11794
commit 9fd0fcb2fa
4 changed files with 111 additions and 54 deletions

View File

@@ -1,57 +1,27 @@
import matplotlib.pyplot as plt
import numpy as np
""" #plt.style.use('_mpl-gallery')
""" class Grafico:
# plot
fig, ax = plt.subplots()
def __init__(self):
self.x = np.linspace(-10, 10, 100) #Variazione di X per disegnare la retta penso
plt.title('AND Logico')
plt.xlabel('X1')
plt.ylabel('X2')
#AND Logico
ax.plot(0, 0, 'o', markeredgewidth=2)
ax.plot(0, 1, 'o', markeredgewidth=2)
ax.plot(1, 0, 'o', markeredgewidth=2)
ax.plot(1, 1, 'x', markeredgewidth=2)
plt.xlim(0, 2)
plt.ylim(0, 2)
def disegna_and(self):
plt.plot(0, 0, 'o', color='red', markeredgewidth=10)
plt.plot(0, 1, 'o', color='red',markeredgewidth=10)
plt.plot(1, 0, 'o', color='red',markeredgewidth=10)
plt.plot(1, 1, 'o', color='green',markeredgewidth=10)
ax.plot(0.5, 0.7, linewidth=2.0)
#ax.plot(x2, y2 - 2.5, 'o-', linewidth=2)
#ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
# ylim=(0, 8), yticks=np.arange(1, 8))
plt.show() """
# Definisci i parametri della retta
m = 2 # coefficiente angolare
q = 1 # intercetta
# Crea un array di valori x
x = np.linspace(0, 2, 100) # 100 punti tra -10 e 10
# Calcola i valori di y usando l'equazione della retta
y = m * x + q
# Crea il grafico
#plt.figure(figsize=(8, 6)) #Grandezza finestra
#plt.plot(x, y, label=f'y = {m}x + {q}', color='blue') # RETTA
plt.title('AND Logico')
plt.xlabel('X1')
plt.ylabel('X2')
#AND Logico
plt.plot(0, 0, 'o', color='red', markeredgewidth=10)
plt.plot(0, 1, 'o', color='red',markeredgewidth=10)
plt.plot(1, 0, 'o', color='red',markeredgewidth=10)
plt.plot(1, 1, 'o', color='green',markeredgewidth=10)
plt.axhline(0, color='black',linewidth=0.5, ls='--')
plt.axvline(0, color='black',linewidth=0.5, ls='--')
#plt.grid(color = 'gray', linestyle = '--', linewidth = 0.5)
plt.legend()
plt.xlim(0, 2)
plt.ylim(0, 2)
plt.show()
def mostra(self):
plt.show()
grafico = Grafico()
grafico.disegna_and()
grafico.mostra() """