Horizontal line in R plotly, when xaxis is discrete
<p>I would like to create a <code>bar plot</code> (with the <code>plotly</code> package), which (for some months) would have <code>red horizontal line</code> (gain to obtain). Plots below show my problem more precisely, I hope.</p>

<p><a href="https://i.stack.imgur.com/BfY5Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BfY5Q.png" alt="enter image description here"></a></p>

<p>Code and data needed to obtain first plot: </p>

<pre><code>library("plotly")
library("dplyr")

data.frame(miesiac_label = as.character(as.roman(c(1:12))),
           miesiac = c(1:12),
           ile = c(12000, 12100, 11100, 12000, 12000, 11900, 12200, 12100, 6000, 12100, 12100, 12100),
           gain = c(rep(NA, 7), 11000, 12000, 12000, 12000, 12000)) -&gt; dane
dane$miesiac_label &lt;- factor(dane$miesiac_label, levels = dane[["miesiac_label"]])

plot_ly(dane) %&gt;%
    add_trace(x = ~miesiac_label, y = ~ile,
              type = 'bar', marker = list(color = '#99d3df')) %&gt;%
    add_trace(x = ~miesiac_label, y = ~gain, name = 'Gain', 
              type = "scatter", mode='lines+markers', marker = list(color = 'red'),
              line = list(color = 'red'))
</code></pre>

<p>I think that I should have a continuous scale to do this and after this just change <code>x axis labels</code>, but I don't know how to change those labels (I've tried to find it in google first, of course)...</p>

<p>Thanks a lot for your help!</p>