Plotly.graph_objects has no attribute Figure

Hi,

I am trying to display a horizontal bar chart and copied the following code from the plotly.com site but I am getting ‘plotly.graph_objects’ has no attribute ‘Figure’ error both on client and server sides.

I thought Anvil was on Plotly v3.10 hence the error but I believe it has now been upgraded to 4.

Any thoughts why I am getting this error?

Code Sample:

import plotly.graph_objects as go

fig = go.Figure(go.Bar(
            x=[20, 14, 23],
            y=['giraffes', 'orangutans', 'monkeys'],
            orientation='h'))

fig.show()

Thanks,

Hi @mgenc99,

Sorry for the delayed response! If you haven’t solved your issue already, all you need to do is drop a Plot component to your form, and then you can change it’s data property. Like this:

    self.plot_1.data = go.Bar(
            x=[20, 14, 23],
            y=['giraffes', 'orangutans', 'monkeys'],
            orientation='h')
1 Like