Search code examples
rplotlyscatter-plotmarkers

Remove marker border/line in scatterplot plotly R


This is my code:

BD_mapinc <- plot_ly(BD_tab, x=~East, y=~North, type='scatter', mode='markers',
                      text= ~paste("BD incr:", BD_tab$BD_incr, "No.:", Label),
                      size= ~BD_tab$BD_incr,
                      marker=list(color = ~BD_tab$BD_incr,
                                  colorbar=list(title='BD increment [%]'),
                                  colorscale='PuOr')
                      ) %>%
      layout(plot_bgcolor='#e5ecf6', 
             xaxis = list( 
               zerolinecolor = '#ffff', 
               zerolinewidth = 2, 
               gridcolor = 'ffff'), 
             yaxis = list( 
               zerolinecolor = '#ffff', 
               zerolinewidth = 2, 
               gridcolor = 'ffff'))
)
      
BD_mapinc

Ever since I found out how to add a title to the colorscale with the marker option, I also have unwanted marker borders. Can someone help me? How can I remove them? What the plot currently looks like


Solution

  • You can move some of your arguments into the marker function and set line width to zero to remove the lines around the markers:

    BD_mapinc <- plot_ly(BD_tab, x=~East, y=~North, type='scatter', mode='markers',
                         text= ~paste("BD incr:", BD_tab$BD_incr, "No.:", Label),
                         marker=list(color = ~BD_tab$BD_incr,
                                     colorbar=list(title='BD increment [%]'),
                                     colorscale='PuOr',
                                     size= ~BD_tab$BD_incr,
                                     line=list(width=0)))%>%
      layout(plot_bgcolor='#e5ecf6', 
             xaxis = list( 
               zerolinecolor = '#ffff', 
               zerolinewidth = 2, 
               gridcolor = 'ffff'), 
             yaxis = list( 
               zerolinecolor = '#ffff', 
               zerolinewidth = 2, 
               gridcolor = 'ffff'))