Skip to content
Snippets Groups Projects
Commit 4c06c900 authored by Laura Marcela Becerra's avatar Laura Marcela Becerra
Browse files

change figure

parent 064a937b
No related branches found
No related tags found
No related merge requests found
...@@ -162,6 +162,9 @@ display(bucaramanga_map) ...@@ -162,6 +162,9 @@ display(bucaramanga_map)
import pandas as pd import pandas as pd
import numpy as np import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import plotly.express as px import plotly.express as px
import plotly.graph_objects as go import plotly.graph_objects as go
...@@ -176,6 +179,9 @@ Estaciones = [('E2_00023','Grupo Halley',7.1393716,-73.1210968), ...@@ -176,6 +179,9 @@ Estaciones = [('E2_00023','Grupo Halley',7.1393716,-73.1210968),
('mE1_00012','I.E. Café Madrid',7.1631654, -73.14033300) ('mE1_00012','I.E. Café Madrid',7.1631654, -73.14033300)
] ]
fecha_inicio = "2023-02-24 00:00:00"
fecha_fin = "2023-12-20 00:00:00"
Nest=len(Estaciones) Nest=len(Estaciones)
data=[[] for i in range(Nest)] data=[[] for i in range(Nest)]
...@@ -204,86 +210,60 @@ for i in range(1,Nest): ...@@ -204,86 +210,60 @@ for i in range(1,Nest):
data[i]['Estacion'] = est[1] data[i]['Estacion'] = est[1]
data[i]['id_est'] = int(i) data[i]['id_est'] = int(i)
for i in range(1,Nest):
data[i] = data[i].assign(row_number=range(len(data[i])))
data[i]['ts'] = data[i].index
data[i].set_index(['row_number'], inplace=True)
dat[i] = dat[i].assign(row_number=range(len(dat[i])))
dat[i]['ts'] = dat[i].index
dat[i].set_index(['row_number'], inplace=True)
data_all = data[1].copy() fig = plt.subplots(figsize=(20,20))
dat_all = dat[1].copy()
for i in range(2,Nest):
data_all = data_all.merge(data[i], how='outer')
dat_all = dat_all.merge(dat[i], how='outer')
col = 2
row = int( (Nest-1)/col )
i=0; j=0
for ii in range(1,Nest):
ax = plt.subplot2grid((row,col), (j,i) )
# Crear gráfico
data[ii].pm25.plot(ax=ax,label=' ' , marker='o',ls="", markersize=0.5, alpha=0.2)
dat[ii].pm25_r.plot(ax=ax,label=' Promedio PM 25 ', ls="-", color="navy")
fig = px.scatter(data_all, x="ts", y="pm25", ax.axhline(y=37, color='r', linestyle='--', label='Nivel Máximo Permisible 24 horas (37 $\mu g /m^3$)')
color="Estacion", hover_name="Estacion" ax.axhline(y=12, color='orange', linestyle='--', label='Nivel Aceptable Permisible 24 horas (12 $\mu g /m^3$)')
)
Ndat= dat[ii].shape[0]
ax.text(dat[ii].index[int(0.5*Ndat)], 50, Estaciones[ii][1], ha="center", va="bottom", fontsize=25, fontweight="bold")
fig2 = px.line(dat_all, x="ts", y="pm25_r", if i==0:
color="Estacion", ax.set_ylabel("PM 25 $[\, \mu g / m^3\, ]$", fontsize=25, fontweight="bold")
hover_name="Estacion" ) ax.tick_params(which='major', pad=1, length=8, labelsize=15, direction="inout", width=1.5)
fig.update_traces(marker={'size': 2, 'opacity':0.3 }) if j==0:
ax.legend(loc="upper left")
fig3 = go.Figure(data=fig.data + fig2.data) else:
ax.axes.yaxis.set_visible(False)
fig3.add_hline(y=12, line_dash="dot", row="all", col="all",
annotation_text="<b>Nivel Aceptable Permisible 24 horas</b> <br> (12 \mu g /m^3)",
annotation_position="bottom right", if j==(row-1):
line_color="yellow", ax.xaxis.set_major_formatter(mdates.DateFormatter('%b'))
annotation=dict(font_size=12, font_family="Times New Roman"),) plt.xticks(rotation=0)
ax.set_xlabel("")
fig3.add_hline(y=37, line_dash="dot", row="all", col="all", #ax.xaxis.set_major_locator(mdates.DayLocator(interval=32))
annotation_text="<b>Nivel Máximo Permisible 24 horas</b> <br> (37 \mu g /m^3)", ax.tick_params(which='minor', labelsize=18, length=8)
annotation_position="bottom right",
line_color="red", else:
annotation=dict(font_size=12, font_family="Times New Roman"),) ax.axes.xaxis.set_visible(False)
fig3.update_layout ( xaxis_title="Fecha",
yaxis_title="PM 25 [ \mu g / m^3 ]", ax.set_ylim(-2., 75)
autosize=True, ax.set_xlim(fecha_inicio, fecha_fin)
#width=790,
#height=500, i+=1
margin=dict( if i > (col-1):
l=50, i=0
r=50, j+=1
b=50,
t=50,
pad=4), plt.subplots_adjust(left=0.06, bottom=0.1, right=0.99, top=0.99, wspace=0.01, hspace=0)
font=dict(
family="Rockwell", plt.show()
size=12,
#color="RebeccaPurple"
),
legend=dict(
title=None, orientation="h", y=1.05, yanchor="bottom", x=0.5, xanchor="center"
),
plot_bgcolor='rgba(0,0,0,0)'
)
fig3.update_xaxes( ticks='outside',
showline=True,
linecolor='black',
#mirror=True,
#range=[1600,2020],
)
fig3.update_yaxes( #ticks='outside',
#showline=True,
#linecolor='black',
#mirror=True,
range=[-2,75],
)
fig3.show()
``` ```
...@@ -315,6 +295,7 @@ Estaciones = [('E2_00023','Grupo Halley',7.1393716,-73.1210968), ...@@ -315,6 +295,7 @@ Estaciones = [('E2_00023','Grupo Halley',7.1393716,-73.1210968),
('mE1_00012','I.E. Café Madrid',7.1631654, -73.14033300) ('mE1_00012','I.E. Café Madrid',7.1631654, -73.14033300)
] ]
Nest=len(Estaciones) Nest=len(Estaciones)
data=[[] for i in range(Nest)] data=[[] for i in range(Nest)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment