Skip to content

Instantly share code, notes, and snippets.

@aletelecom
aletelecom / .py
Created July 31, 2022 18:50
Viz 4 function call
double_hist_and_scatter_plot(data_df)
@aletelecom
aletelecom / .py
Created July 31, 2022 18:38
Viz 4 visualization
def double_hist_and_scatter_plot(df):
# Auxilliary parameters for the plot, number of bins
w = 2
n = math.ceil((df['optical_power'].max() - df['optical_power'].min()) / w)
# definitions for the axes limits and positions
left, width = 0.1, 0.65
bottom, height = 0.1, 0.65
spacing = 0.005
@aletelecom
aletelecom / .py
Created July 31, 2022 17:56
Viz 4 dataset creation
data_df = pd.DataFrame([distance, np.sort(optical_power)])
data_df = data_df.T
data_df.rename(columns={0:'distance', 1:'optical_power'}, inplace=True)
#data_df['avg_speed'] = data_df['throughput'].divide(data_df['client_qty'])
data_df
@aletelecom
aletelecom / .py
Created July 31, 2022 17:54
Viz 4 optical power dist
loc = -15
scale = 4
size = 1200
optical_power = norm.rvs(loc, scale, size, random_state=28)
plt.hist(np.sort(optical_power))
plt.show()
@aletelecom
aletelecom / .py
Created July 31, 2022 17:49
Viz 4 distance variable
a = 10
loc = 4000
scale = 2000
size = 1200
distance = skewnorm.rvs(a, loc, scale, size, random_state=28)
plt.hist(np.sort(distance))
plt.show()
@aletelecom
aletelecom / .py
Created July 31, 2022 17:48
Viz 4 imports
# Make all the imports needed
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm, skewnorm
import math
@aletelecom
aletelecom / .py
Created July 29, 2022 13:57
Viz 3 complete
plt.rcParams.update({'font.size':15, 'figure.figsize': (20,8)})
fig, ax = plt.subplots()
avg_speed = data_df['avg_speed']
client_per_olt = data_df['client_qty']
throughput_olt = data_df['throughput']
colors = data_df['colors']
scatter = ax.scatter(x=client_per_olt, y=avg_speed, c=colors.astype('category').cat.codes*100, s=avg_speed*400, alpha=0.3, cmap='prism')
@aletelecom
aletelecom / .py
Created July 29, 2022 13:55
Viz 3 part 4
classes = ('gt 6Mbps','2Mbps & 6Mbps', 'lt 2Mbps')
legend1 = ax.legend(handles=scatter.legend_elements()[0]*10, labels=classes, loc='upper right', title='Legend')
ax.add_artist(legend1)
ax.set_ylim(0,20)
plt.xlabel('Client quantity per OLT')
plt.ylabel('Total Thoughput per OLT (Mbps)')
plt.show()
@aletelecom
aletelecom / .py
Created July 29, 2022 13:54
Viz 3 part 3
lowest_t = throughput_olt.min()
hypothetical_olt = 'Highest speed per client OLT'
annotation = ax.annotate('{}'.format(hypothetical_olt), xytext=(.15,.5), xy=(800,15), xycoords='data', textcoords='axes fraction', arrowprops=dict(arrowstyle="->",
connectionstyle="arc3"))
ax.add_artist(annotation)
@aletelecom
aletelecom / .p
Created July 29, 2022 13:53
Viz 3 part 2
scatter = ax.scatter(x=client_per_olt, y=avg_speed, c=colors.astype('category').cat.codes*100, s=avg_speed*400, alpha=0.3, cmap='prism')