Polar subplots in plotly.py 3.0.0


#1

I am trying to get polar subplots working in the new version of plotly.py, but this example returns the following:

ValueError: Invalid properties specified for object of type plotly.graph_objs.Layout: ('polar4', 'polar2', 'polar3').

Also, trying to get polar subplots working with the subplot instructions provided with the plotly.py update here (plotly.tools.make_subplots and add_trace) leads to:

ValueError: Invalid property specified for object of type plotly.graph_objs.Scatterpolar: 'xaxis'
(despite not explicitly specifying an xaxis attribute).

Any help would be appreciated, thanks.


#2

Hey @tks

Does this way work for you?

import plotly.plotly as py

data = [
    {
        'type': 'scatterpolar',
        'r': [1, 2, 3],
        'theta': [50, 100, 200],
        'marker': dict(symbol = "square")
    },
    {
        'type': 'scatterpolar',
        'r': [1, 2, 3],
        'theta': [1, 2, 3],
        'thetaunit': "radians"
    },
    {
        'type': 'scatterpolar',
        'r': ["a", "b", "c", "b"],
        'theta': ["D", "C", "B", "A"],
        'subplot': "polar2"
    },
    {
        'type': 'scatterpolar',
        'r': [50, 300, 900],
        'theta': [0, 90, 180],
        'subplot': "polar3"
    },
    {
        'type': 'scatterpolar',
        'mode': "lines",
        'r': [3, 3, 4, 3],
        'theta': [0, 45, 90, 270],
        'fill': "toself",
        'subplot': "polar4"
    }
]

layout = {
    'polar': dict(
      domain = dict(
        x = [0, 0.46],
        y = [0.56, 1]
      ),
      radialaxis = dict(
        range = [1, 4]
      ),
      angularaxis = dict(
        thetaunit = "radians"
      )
    ),
    'polar2': dict(
      domain = dict(
        x = [0, 0.46],
        y = [0, 0.42]
      )
    ),
    'polar3': dict(
      domain = dict(
        x = [0.54, 1],
        y = [0.56, 1]
      ),
      radialaxis = dict(
        type = "log",
        tickangle = 45
      ),
      sector = [0, 180]
    ),
    'polar4': dict(
      domain = dict(
        x = [0.54, 1],
        y = [0, 0.44]
      ),
      radialaxis = dict(
          visible = False,
          range = [0, 6]
      )
    ),
    'showlegend': False
}

fig = {'data':data,'layout':layout}
py.iplot(fig, validate=False)

#3

Thanks for the reply @bcd. I should have specified that I am trying to generate the polar subplots within a go.FigureWidget in JupyterLab. Your example with iplot works, but a go.FigureWidget(fig) wrapper around the fig in your example fails with the first ValueError I listed originally.


#4

See https://github.com/plotly/plotly.py/pull/1057 for progress. Thanks!