0

I need to change the x-axis of this chart. The dataframe has time data per day, from 2012 to October 2022. I want to be able to see in the xaxis all the years and the chart shows me only every 2 years.

import plotly.express as px



fig = px.line(data_SPY, y=['Close'], line_shape='linear', color_discrete_sequence=["#930435"],
              labels={'value': "Precio", 'Date': "Fecha"})
fig.update_layout(
    showlegend=False,
    title= 'Precio SPY ETF',
    font_color= "#000000",
    font_family="Tahoma",
    xaxis = dict(
        tickangle = 0,
        ticklabelstep=1,
        showgrid=True,   
    ), 
    yaxis = dict(
        showgrid=True
    ), 
   legend = dict(
     orientation='v'
   ), 
    paper_bgcolor='#FFFFFF'
)
fig.show(renderer="iframe")

enter image description here

1 Answers1

0

You'd need to specify the dtick.

fig.update_xaxes(dtick='Y1')
amance
  • 883
  • 4
  • 14