From a267d1179497e2066b9cb15e9c656c1f59f4e42c Mon Sep 17 00:00:00 2001 From: mirimatcode Date: Thu, 23 Jan 2025 14:26:25 +0100 Subject: [PATCH] lavoro al grafico --- README.md | 4 ++++ grafico.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 2 ++ 3 files changed, 63 insertions(+) create mode 100644 grafico.py create mode 100644 requirements.txt diff --git a/README.md b/README.md index a8018c7..9650284 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/grafico.py b/grafico.py new file mode 100644 index 0000000..161e608 --- /dev/null +++ b/grafico.py @@ -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() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8248f97 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +matplotlib +numpy \ No newline at end of file