lavoro al grafico
This commit is contained in:
@@ -1,2 +1,6 @@
|
||||
# percettroni
|
||||
|
||||
## Preparazione ambiente Python
|
||||
- Creare macchina virtuale ('python -m venv venv')
|
||||
- Attivare macchina virtuale ('source venv/bin/activate')
|
||||
- Installazione librerie (pip install -r requirements.txt)
|
||||
|
||||
57
grafico.py
Normal file
57
grafico.py
Normal file
@@ -0,0 +1,57 @@
|
||||
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()
|
||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
matplotlib
|
||||
numpy
|
||||
Reference in New Issue
Block a user