title: How to remove 0 y values plotly R?
body: <p>I have the following code and dataframe :</p>
  <pre><code>datasku = data.frame(matrix(ncol = 3, nrow = 12))
  names_col = c(&quot;product&quot;, &quot;Bad Waitress&quot;, &quot;Black Pumas&quot;)
  colnames(datasku)  = names_col
  datasku$product &lt;- c(&quot;x&quot;,&quot;y&quot;,&quot;s&quot;,&quot;u&quot;,&quot;i&quot;,&quot;o&quot;,&quot;l&quot;,&quot;m&quot;,&quot;n&quot;,&quot;k&quot;,&quot;b&quot;,&quot;c&quot;)
  artists &lt;- c(&quot;Bad Waitress&quot;, &quot;Black Pumas&quot;)
  datasku$`Bad Waitress`&lt;- c(23,40,0,0,0,0,0,0,10,0,0,0)
  datasku$`Black Pumas` &lt;- c(0,40,0,0,0,65,0,0,10,0,0,0)
  
   product Bad Waitress Black Pumas
  1        x           23           0
  2        y           40          40
  3        s            0           0
  4        u            0           0
  5        i            0           0
  6        o            0          65
  7        l            0           0
  8        m            0           0
  9        n           10          10
  10       k            0           0
  11       b            0           0
  12       c            0           0
  
  show_vec = c()
  
  for (i in 1:length(artists)){
    show_vec = c(show_vec,FALSE)
  }
  get_menu_list &lt;- function(artists){
    n_names = length(artists)
    buttons = vector(&quot;list&quot;,n_names)
    
    for(i in seq_along(buttons)){
      show_vec[i] = TRUE
      buttons[i] = list(list(method = &quot;restyle&quot;,
                             args = list(&quot;visible&quot;, show_vec),
                             label = artists[i]))
      print(list(show_vec))
      show_vec[i] = FALSE
    }
    
    return_list = list(
      list(
        type = 'dropdown',
        active = 0,
        buttons = buttons
      )
    )
    
    return(return_list)
  }
  print(get_menu_list(artists)) 
  fig &lt;- plot_ly(data=datasku, x = ~product, y = ~`Bad Waitress`,type = 'bar',
                 transforms = list(
                   list(
                     type = 'filter',
                     target = 'y',
                     operation = '&gt;',
                     value = 0
                   )),
                 hovertemplate = paste('&lt;i&gt;Popularity&lt;/i&gt;: %{y:.2f}%',
                                       '&lt;br&gt;&lt;i&gt;Product&lt;/i&gt;: %{x}&lt;extra&gt;&lt;/extra&gt;&lt;br&gt;'))
  fig &lt;- fig %&gt;% add_trace(y = ~`Black Pumas`)
  fig &lt;- fig %&gt;% layout(showlegend = F,yaxis = list(title = 'Count'), barmode = 'group',
                        updatemenus = get_menu_list(artists))
  fig
  </code></pre>
  <p>What this code does is basically create a plotly barchart with dropdown menus corresponding to the artists names. When clicking an artist it should only show the products which have a values &gt;0 but it is partially working and I can't understand why.
  If I run the code and select Bad Waitress this is what I obtain :</p>
  <p><a href="https://i.stack.imgur.com/JOtO3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JOtO3.png" alt="enter image description here" /></a></p>
  <p>As you can see some columns are removed (since they have 0 value) but others, which have 0 value they are still shown despite the filter. How can I solve this problem?</p>
  <p>Thank you</p>