title: Plotly - Plot 2 Y Axes With Time Series
body: <p>I am trying to use r plotly to plot a chart that has following features:</p>
  
  <ol>
  <li>Date objects as X-variable</li>
  <li><p>2 line plots in one charts with 2 Y-axis: one on the left, the other on the     right</p>
  
  <pre><code>Date              Amount1          Amount2
  2/1/2017          19251130        21698.94
  2/2/2017          26429396        10687.37
  2/5/2017            669252            0.00
  2/6/2017          25944054        11885.10
  2/7/2017          27895562        14570.39
  2/8/2017          20842279        20080.56
  2/9/2017          25485527         9570.51
  2/10/2017          17008478        14847.49
  2/11/2017            172562            0.00
  2/12/2017            379397          900.00
  2/13/2017          25362794        18390.80
  2/14/2017          26740881        11490.94
  2/15/2017          20539413        22358.26
  2/16/2017          22589808        12450.45
  2/17/2017          18290862         3023.45
  2/19/2017           1047087          775.00
  2/20/2017           4159070         4100.00
  2/21/2017          28488401        22750.35
  </code></pre></li>
  </ol>
  
  <p>and the code I use is:</p>
  
  <pre><code>      ay &lt;- list(
      #tickfont = list(color = "red"),
      overlaying = "y",
      side = "right"
    )
  
    p &lt;- plot_ly() %&gt;%
      add_lines(x = df$Date, y = df$Amount1, name = "Amount1",type = "scatter", mode = "lines") %&gt;%
      add_lines(x = df$Date, y = df$Amount2, name = "Amount2", yaxis = "y2",type = "scatter", mode = "lines") %&gt;%
      layout(
        title = "Chart Summary", yaxis2 = ay,
        xaxis = list(title="Date")
      )
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/QzxuR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QzxuR.jpg" alt="Chart"></a></p>
  
  <p>The output chart looks fine but the date intervals on the X-axis is looking bad. I am wondering what is the solution to this, and if I want to have 2 histograms in one chart using the data above, what is the optimal way to do it?</p>
  
  <p>Thank you for help!</p>