plot legend

This commit is contained in:
Tr1xt4n 2023-04-14 21:01:23 +02:00
parent 2307fd2567
commit 4f110cc7cb

View File

@ -3,7 +3,7 @@ import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
nb_files = os.listdir(".." + os.sep + "export")
nb_files = os.listdir("PF")
size = len(nb_files)
@ -29,7 +29,7 @@ def rb_available(arr: list[tuple[int, np.ndarray]]) -> np.ndarray:
nb = 0
for nb_users, data in arr:
available[nb, 0] = nb_users
available[nb, 1] = (data.shape[0] / (200 * 10000)) * 100
available[nb, 1] = (data.shape[0] / (200 * 20000)) * 100
nb += 1
return available
@ -64,12 +64,12 @@ def rb_allocate_distance(arr: list[tuple[int, np.ndarray]], distance) -> np.ndar
np_arr: list[tuple[int, np.ndarray]] = list()
for i in nb_files:
np_arr.append((int(i.split(".")[0]), pd.read_csv(".." + os.sep + "export" + os.sep + i, delimiter=';').to_numpy()))
np_arr.append((int(i.split(".")[0]), pd.read_csv("PF" + os.sep + i, delimiter=';').to_numpy()))
averages = mean_mkn(np_arr)
available = rb_available(np_arr)
allocate_lp1 = rb_allocate_distance(np_arr, 150)
allocate_lp1 = rb_allocate_distance(np_arr, 100)
allocate_lp2 = rb_allocate_distance(np_arr, 500)
allocate_total = allocate_lp1[:, 1] + allocate_lp2[:, 1]
@ -83,31 +83,34 @@ del np_arr
fig, ax = plt.subplots(2, 2)
ax[0, 0].plot(averages[:, 0], averages[:, 1], marker="o")
ax[0, 0].set(xlabel='number of users', ylabel='Efficacité spectrale', title='Efficacité spectrale')
ax[0, 0].set(xlabel='number of users', ylabel='% Spectral efficiency', title='Spectral efficiency PF')
ax[0, 0].grid()
ax[0, 0].set_ylim([24, 32])
ax[0, 0].set_ylim([0, 40])
ax[0, 1].plot(available[:, 0], available[:, 1], marker="o")
ax[0, 1].set(xlabel='number of users', ylabel='RB utilisés', title='Pourcentage de RB utilisés')
ax[0, 1].set(xlabel='number of users', ylabel=' % RB used', title='Percentage of RB used PF')
ax[0, 1].grid()
ax[0, 1].set_ylim([0, 205])
ax[0, 1].set_ylim([0, 105])
ax[1, 0].plot(delays[:, 0], delays[:, 1], marker="o")
ax[1, 0].set(xlabel='number of users', ylabel='delays(ms)', title='Delay')
ax[1, 0].set(xlabel='number of users', ylabel='delay(ms)', title='Delay PF')
ax[1, 0].grid()
available.sort(axis=0)
#ax[1, 1].scatter(allocate_lp1[:, 0], (allocate_lp1[:, 1]/(allocate_lp1[:, 1])+allocate_lp2[:, 1])*100)
ax[1, 1].plot(available[:, 0], (allocate_lp1[:, 1]/(allocate_lp1[:, 1]+allocate_lp2[:, 1])*100))
ax[1, 1].plot(available[:, 0], (allocate_lp1[:, 1]/(allocate_lp1[:, 1]+allocate_lp2[:, 1])*100), label="100 meters group")
#ax[1, 1].scatter(allocate_lp2[:, 0], (allocate_lp2[:, 1]/(allocate_lp1[:, 1])+allocate_lp2[:, 1])*100)
ax[1, 1].plot(available[:, 0], (allocate_lp2[:, 1]/(allocate_lp1[:, 1]+allocate_lp2[:, 1])*100))
#ax[1, 1].plot(available[:, 0], available[:, 1], marker="o", label="RB used")
ax[1, 1].set(xlabel='number of users', ylabel='RB utilisés proche/loin/total', title='RB utilisés distance')
ax[1, 1].plot(available[:, 0], (allocate_lp2[:, 1]/(allocate_lp1[:, 1]+allocate_lp2[:, 1])*100), label="500 meters group")
ax[1, 1].set(xlabel='number of users', ylabel='% RB used', title='RB used depending on the distance PF')
ax[1, 1].grid()
ax[1, 1].set_ylim([0, 100])
ax[1, 1].set_ylim([0, 105])
ax[1, 1].legend(loc="upper left")
plt.show()