Invalid property specified for object of type plotly.graph_objs.Layout: 'colorbar'

I was following the example given

but facing a error:-

ValueError: Invalid property specified for object of type plotly.graph_objs.Layout: ‘colorbar’

i have tried this on local machine, google colab with plotly.version == 3.5.0

on google search i could not find any such error.

if i remove all the elements with error , then an empty plot is shown.

Hi @rohit3463,

Yeah, I’m not sure what that layout.colorbar property is doing there, but that’s not valid in recent versions of plotly.py. I opened an issue at https://github.com/plotly/documentation/issues/1250.

When I remove the colorbar property the plot seems to be working for me. I also converted it to offline mode

from plotly.offline import iplot, init_notebook_mode
import pandas as pd
init_notebook_mode()

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv')
df.head()

df['text'] = df['airport'] + '' + df['city'] + ', ' + df['state'] + '' + 'Arrivals: ' + df['cnt'].astype(str)

scl = [ [0,"rgb(5, 10, 172)"],[0.35,"rgb(40, 60, 190)"],[0.5,"rgb(70, 100, 245)"],\
    [0.6,"rgb(90, 120, 245)"],[0.7,"rgb(106, 137, 247)"],[1,"rgb(220, 220, 220)"] ]

data = [ dict(
        type = 'scattergeo',
        locationmode = 'USA-states',
        lon = df['long'],
        lat = df['lat'],
        text = df['text'],
        mode = 'markers',
        marker = dict(
            size = 8,
            opacity = 0.8,
            reversescale = True,
            autocolorscale = False,
            symbol = 'square',
            line = dict(
                width=1,
                color='rgba(102, 102, 102)'
            ),
            colorscale = scl,
            cmin = 0,
            color = df['cnt'],
            cmax = df['cnt'].max(),
            colorbar=dict(
                title="Incoming flightsFebruary 2011"
            )
        ))]

layout = dict(
        title = 'Most trafficked US airports<br>(Hover for airport names)',
        geo = dict(
            scope='usa',
            projection=dict( type='albers usa' ),
            showland = True,
            landcolor = "rgb(250, 250, 250)",
            subunitcolor = "rgb(217, 217, 217)",
            countrycolor = "rgb(217, 217, 217)",
            countrywidth = 0.5,
            subunitwidth = 0.5
        ),
    )

fig = dict( data=data, layout=layout )
iplot(fig)

Do you still get an empty plot even with this offline version?

-Jon

Yes, i tried removing colorbar property it is working on the local machine but it is still showing an empty plot on google colab.

use the below to get the graph as colab block the graph

fig.show(renderer=“colab”)