Hello everyone,
I have a little problem to format a graph on Plotly. Indeed, my dataframe has in index values of type DateTime which gives me dates on the x axis. The result suits me perfectly, except that I would like the year not to be displayed but keeping the same graduations (day and time) as on the graph already obtained.
I have already made several researches and tried some solutions without getting a satisfactory resultâŠ
import plotly.graph_objects as go
from plotly.subplots import make_subplotsfig = make_subplots(rows=2, specs=[[{âsecondary_yâ: True}],[{âsecondary_yâ: True}]])
Add traces
fig.add_trace(
go.Scatter(x=resul_active_winter_use.loc[period_winter].index,
y=resul_active_winter_use.loc[period_winter][âT_extâ], name=âT_extâ),
secondary_y=False,row=1, col=1
)
fig.add_trace(
go.Scatter(x=resul_active_winter_use.loc[period_winter].index,
y=resul_active_winter_use.loc[period_winter][âT_SHflâ], name=âT_SHflâ),
secondary_y=False,row=1, col=1
)
fig.add_trace(
go.Scatter(x=resul_active_winter_use.loc[period_winter].index,
y=resul_active_winter_use.loc[period_winter][âT_SHfl_setâ], name=âT_SHfl_setâ),
secondary_y=False,row=1, col=1
)fig.add_trace(
go.Scatter(x=resul_active_winter_use.loc[period_winter].index,
y=resul_active_winter_use.loc[period_winter][âP_SHâ], name=âP_SHâ, line=dict(dash=âdotâ) ),
secondary_y=True,row=1, col=1
)fig.add_trace(
go.Scatter(x=resul_active_winter_use.loc[period_winter].index,
y=resul_active_winter_use.loc[period_winter][âeff_SSTâ], name=âeff_SSTâ),
secondary_y=False,row=2, col=1
)
fig.add_trace(
go.Scatter(x=resul_active_winter_use.loc[period_winter].index,
y=resul_active_winter_use.loc[period_winter][âkâ], name=âkâ),
secondary_y=True,row=2, col=1
)fig.update_layout(title=âEtude saisonniĂšre - Hiverâ,
#xaxis_title=â% Variationâ,
#yaxis_title=âP_SSTâ,
#legend_font_size=18,
#xaxis_title=âTemps [h]â,
#yaxis_title=âTempĂ©rature [°C]â,
template=âsimple_whiteâ,
legend_title_text=ââ,
font_size=14,
autosize=False,
width=1000,
height=1000,
margin=dict(
l=50,
r=50,
b=100,
t=100,
pad=4)
)fig.update_xaxes(title_text=âDateâ)
fig.update_yaxes(title_text=âTempĂ©rature [°C]â, secondary_y=False, col=1, row=1)
fig.update_yaxes(title_text=âPuissance chauffage [kW]â, secondary_y=True, col=1, row=1)fig.update_yaxes(title_text=âEfficacitĂ©â, secondary_y=False, col=1, row=2)
fig.update_yaxes(title_text=âRapport kâ, secondary_y=True, col=1, row=2)#fig.update_xaxes(
#dtick=âM1â,
tickformat=â%d\n%bâ)
fig.show()
If someone can bring me a solution I would be really grateful.
Thanks in advance,
Alexis