correcciones y ajustes a las gráficas de iaux/índices

parent 14370735
......@@ -625,25 +625,35 @@ def update_correlacion(controlado):
datos_sorted = datos_fil.sort_values(by=controlado, ascending=True)
datos_sorted.reset_index(inplace=True)
metricas = ["imc", "age", "glucose", "hba1c"]
figura = make_subplots(rows=2, cols=2, shared_xaxes=True, vertical_spacing=0.1, subplot_titles=metricas)
figura = make_subplots(rows=2, cols=2, vertical_spacing=0.25)
lrow = 1
lcol = 1
seq = 1
for metrica in metricas:
datosfil = datos_sorted[np.abs(stats.zscore(datos_sorted[metrica], nan_policy='omit')) < 3]
figura.add_trace(
go.Scatter(x=datosfil.index, y=datosfil[metrica], name=metrica, mode='markers'),
go.Scatter(x=datos_sorted.index, y=datos_sorted[metrica], name=metrica, mode='markers'),
row=lrow, col=lcol
)
figura.add_trace(
go.Scatter(x=datosfil.index, y=datosfil[metrica].rolling(5).mean(), name="PM(5)"),
go.Scatter(x=datos_sorted.index, y=datos_sorted[metrica].rolling(5).mean(), name="PM(5)"),
row=lrow, col=lcol
)
corr = datos_sorted[[metrica]].corrwith(datos_sorted[controlado]).values[0]
figura.add_annotation(row=lrow, col=lcol, text="R = " + "{:.2f}".format(corr))
figura["layout"]['xaxis' + str(seq)]['title']="Ranqueo de pacientes por su iAUC de" + controlado
figura["layout"]['yaxis' + str(seq)]['title']= metrica
lcol = lcol + 1 if lcol < 2 else 1
lrow = lrow + (lcol % 2)
seq = seq + 1
figura["layout"]["yaxis1"]["range"] = [15,45]
figura["layout"]["yaxis2"]["range"] = [17,80]
figura["layout"]["yaxis3"]["range"] = [60,180]
figura["layout"]["yaxis4"]["range"] = [5,7]
figura.update_layout(showlegend=False)
figura.update_layout(height=600, width=800)
return figura
if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment