57 lines
1.3 KiB
Python
57 lines
1.3 KiB
Python
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
""" #plt.style.use('_mpl-gallery')
|
|
|
|
# plot
|
|
fig, ax = plt.subplots()
|
|
|
|
#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)
|
|
|
|
|
|
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() |