title: How to customize barchart in plotly R?
body: <p>On barchart: 'sale' and 'share' variables are visualized via bars, while 'cost' by a red line. Now I want to drop/remove this red line and keep only numbers into boxes and add corresponding variable in the legend map. Moreover I want to add average value of 'share' as a horizontal line on the Y axis</p>
  <pre><code>df &lt;- data.frame (model  = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;,&quot;D&quot;,&quot;E&quot;,&quot;F&quot;),
                        share = c(12,20,15,9,60,20),
                        sale = c(16,25,18,14,67,28),
                        cost = c(14,19,28,24,57,28))
  
  #set levels of model by cost
  df$model &lt;- factor(df$model, levels = arrange(df, desc(df$cost))$model)
  
  library(tidyverse)
  
  df_long &lt;- df %&gt;% 
    pivot_longer(
      cols = -model
    ) 
  
  
  df_long %&gt;% 
    filter(name != &quot;cost&quot;) %&gt;% 
    plot_ly(x = ~model, y = ~value, color = ~name, type = &quot;bar&quot;, 
            customdata = ~name,  colors = c(&quot;blue&quot;, &quot;gray&quot;),
            hovertemplate = paste0(&quot;Model: %{x}&lt;br&gt;Value: %{y}&lt;br&gt;&quot;,
                                   &quot;Name: %{customdata}&lt;extra&gt;&lt;/extra&gt;&quot;)) %&gt;%
    add_lines(inherit = F, data = df, x = ~model, 
              y = ~cost, color = I(&quot;red&quot;),
              name = &quot;cost&quot;,
              hovertemplate = paste0(&quot;Model: %{x}&lt;br&gt;Value: %{y}&lt;br&gt;&quot;,
                                     &quot;Name: cost&lt;extra&gt;&lt;/extra&gt;&quot;)) %&gt;% 
    add_annotations(data = df, x = ~model, y = ~cost, text = ~cost,
                    bgcolor = &quot;white&quot;, bordercolor = &quot;black&quot;, 
                    xshift = 15, yshift = 15, showarrow = F) %&gt;% 
    layout(barmode = &quot;group&quot;)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Nzzp4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Nzzp4.png" alt="enter image description here" /></a></p>