title: Plotly: How to set custom xticks
body: <p>From <a href="https://plotly.com/python/reference/#scatter" rel="noreferrer">plotly doc</a>:</p>
  
  <blockquote>
    <p><strong><em>layout > xaxis > tickvals:</em></strong></p>
    
    <p>Sets the values at which ticks on this axis
    appear. Only has an effect if <code>tickmode</code> is set to "array". Used with
    <code>ticktext</code>.</p>
    
    <p><strong><em>layout > xaxis > ticktext:</em></strong></p>
    
    <p>Sets the text displayed at the
    ticks position via <code>tickvals</code>. Only has an effect if <code>tickmode</code> is set
    to "array". Used with <code>tickvals</code>.</p>
  </blockquote>
  
  <p>Example:</p>
  
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  import numpy as np
  
  np.random.seed(42)
  feature = pd.DataFrame({'ds': pd.date_range('20200101', periods=100*24, freq='H'), 
                          'y': np.random.randint(0,20, 100*24) , 
                          'yhat': np.random.randint(0,20, 100*24) , 
                          'price': np.random.choice([6600, 7000, 5500, 7800], 100*24)})
  
  
  import plotly.graph_objects as go
  import plotly.offline as py
  import plotly.express as px
  from plotly.offline import init_notebook_mode
  
  init_notebook_mode(connected=True)
  
  
  y = feature.set_index('ds').resample('D')['y'].sum()
  
  fig = go.Figure()
  fig.add_trace(go.Scatter(x=y.index, y=y))
  
  
  x_dates = y.index.to_series().dt.strftime('%Y-%m-%d').sort_values().unique()
  
  
  layout = dict(
      xaxis=dict(
          tickmode="array",
          tickvals=np.arange(0, x_dates.shape[0],2).astype(int),
          ticktext=x_dates[::2],
          tickformat='%Y-%m-%d',
          tickangle=45,
      )
  )
  
  fig.update_layout(layout)
  fig.show()
  
  </code></pre>
  
  <p>Result:</p>
  
  <p><a href="https://i.stack.imgur.com/ieKBY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ieKBY.png" alt="enter image description here"></a></p>
  
  <p>Since length of <code>x_dates[::2]</code> is 50 , the ticknumber doesn't match at all .
  How do I sovle it ??</p>