afinamos los titulos en ejes de algunas figuras

parent 592f4d73
......@@ -16,15 +16,18 @@ server = flask.Flask(__name__)
def datavis(datos):
medidas = ["imc", "age", "glucose", "hba1c", "ct", "hdl"]
fig = make_subplots(rows=2, cols=3, shared_xaxes=True, vertical_spacing=0.1,
subplot_titles=medidas)
fig = make_subplots(rows=2, cols=3, vertical_spacing=0.25)
lcol = 1
lrow = 1
seq = 1
for medida in medidas:
fig.add_trace(
go.Scatter(x=datos["id"], y=datos[medida], name=medida,mode="markers"),
row=lrow, col=lcol
)
fig['layout']['xaxis' + str(seq)]['title']='Patient ID'
fig['layout']['yaxis' + str(seq)]['title']=medida
seq = seq + 1
lrow = lrow + (lcol // 3)
lcol = lcol + 1 if lcol < 3 else 1
fig.update_layout(showlegend = False)
......@@ -32,17 +35,20 @@ def datavis(datos):
def popdist(datos):
medidas = ["imc", "age", "glucose", "hba1c", "ct", "hdl"]
# removemos outliers
fig = make_subplots(rows=2, cols=3, shared_yaxes=True, subplot_titles=medidas)
# remoemos outliers
fig = make_subplots(rows=2, cols=3, vertical_spacing = 0.25 )
lcol = 1
lrow = 1
seq = 1
for medida in medidas:
datosfil = datos[np.abs(stats.zscore(datos[medida], nan_policy='omit')) < 3]
fig.add_trace(
go.Histogram(x=datosfil[medida], name=medida),
row=lrow, col=lcol
)
fig['layout']['xaxis' + str(seq)]['title']=medida
seq = seq + 1
lrow = lrow + (lcol // 3)
lcol = lcol + 1 if lcol < 3 else 1
......@@ -56,44 +62,50 @@ def popdist(datos):
def popcorr(datos):
medidas = [ "glucose", "hba1c", "ct", "hdl", "insuline"]
# removemos outliers
fig = make_subplots(rows=2, cols=3, shared_yaxes=False, subplot_titles=medidas)
fig = make_subplots(rows=2, cols=3, shared_yaxes=False, vertical_spacing=0.25)
lcol = 1
lrow = 1
seq = 1
for medida in medidas:
datosfil = datos[np.abs(stats.zscore(datos[medida], nan_policy='omit')) < 3]
fig.add_trace(
go.Scatter(x=datosfil["imc"], y=datosfil[medida], name=medida, mode="markers"),
row=lrow, col=lcol
)
fig['layout']['xaxis' + str(seq)]['title']='IMC'
fig['layout']['yaxis' + str(seq)]['title']=medida
lrow = lrow + (lcol // 3)
lcol = lcol + 1 if lcol < 3 else 1
seq = seq + 1
fig.update_layout(
bargap=0.05, # gap between bars of adjacent location coordinates
bargroupgap=0.05, # gap between bars of the same location coordinates
showlegend = False
)
return fig
def imc_cat(datos):
medidas = [ "glucose", "hba1c", "ct", "hdl", "insuline"]
grupos = ["LW","NW","OW","O-CI","O-CII","O-CIII"]
datos["imc_cat"] = pd.cut(datos["imc"], bins=[0,18,25,30,35,40,100], labels=grupos)
fig = make_subplots(rows=2, cols=3, shared_yaxes=False, subplot_titles=medidas)
grupos = ["LW","NW","OW","O-CI","O-CII"]
datos["imc_cat"] = pd.cut(datos["imc"], bins=[0,18,25,30,35,40], labels=grupos)
fig = make_subplots(rows=2, cols=3, shared_yaxes=False, vertical_spacing=0.25)
lcol = 1
lrow = 1
seq = 1
for medida in medidas:
datosfil = datos.groupby("imc_cat")[medida].mean()
fig.add_trace(
go.Scatter(x=grupos, y=datosfil, name=medida),
row=lrow, col=lcol
)
fig['layout']['yaxis' + str(seq)]['title']=medida
lrow = lrow + (lcol // 3)
lcol = lcol + 1 if lcol < 3 else 1
seq = seq + 1
fig.update_layout(
showlegend = False
......
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