Black Lives Matter. Please consider donating to Black Girls Code today.

Rectange and lasso missing in toolbar dash python

Trying out dash and cannot figure out why the lasso and rectangle tools are not showing up in my plot if I create the figure as shown below. This is just dummy code, but recreates the problem if I use it in my script. The figure shows up and I can modify it with other parameters, but the lasso and rectangle are not there in the toolbar.

import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go

y = np.random.uniform(-1, 1, 100)
x = np.arange(len(y)) 

trace = go.Scatter(x=x, y=y)
data = [trace]
fig = go.Figure(data=data)

It depends if markers are used in the graph or not. For simple lines the lasso and rectangle do not appear. This can be replicated with the following example from the tutorials.
Can someone comment if this is a bug or a feature?

import plotly.plotly as py
import plotly.graph_objs as go

# Create random data with numpy
import numpy as np

N = 500
random_x = np.linspace(0, 1, N)
random_y = np.random.randn(N)

# Create a trace
trace = go.Scatter(
x = random_x,
y = random_y,
name = "example",

mode = "lines"          # --> rectangle and lasso NOT in toolbox

#mode = "lines+markers" # --> rectangle and lasso in toolbox

data = [trace]

py.iplot(data, filename='basic-line')

This is expected for plotly.js at the moment. Only Mapbox maps and scatter traces with markers enable the lasso. Lasso for bar charts and choropleth maps is currently being added, you can follow the progress in plotly.js here:

1 Like

(As a workaround right now, you can just make the markers transparent or very small)

Small markers was the first thing I tried, but turns out the graphs become laggy for medium to large data sets (< 20 k data points) when using markers.
I ll test if this can be overcome by transparent markers. Thanks!