Make_subplots throwing type error


I’m trying to combine two bar graphs into one in order to share a legend and it’s legend functionality. However, when running the code, I’m getting an error.

Error is as follows:

Traceback (most recent call last):
  File "/root/workspace/pages/", line 302, in time_series_show_snapshot
    row=1, col=1))
TypeError: 'module' object is not callable

The code runs as follows:

    dash.dependencies.Output('snapshot_timeseries', 'figure'),
    dash.dependencies.Input('item_dropdown', 'value'),
def time_series_show_snapshot(item):
    df_table = df_final[df_final['ord_base7']==item].groupby(['ord_base7', 'item_desc','model', 'snapshot']).agg({'diff':'sum',
    'predicted_sales':'sum', 'sales_dollars':'sum'}).reset_index()
    df_table.loc[:, 'MAPE'] = np.round(df_table.loc[:, 'diff']/ df_table.loc[:, 'sales_dollars'], 4)
    df_table.loc[:, 'ACCURACY'] = 1 - df_table.loc[:,'MAPE']
    df_table.loc[:, 'BIAS'] = np.round((df_table.loc[:,'predicted_sales']- df_table.loc[:, 'sales_dollars'])/ df_table.loc[:, 'sales_dollars'], 4)
    # print("Data for time series", df_[['dmand_yr_mo', 'ord_base7', 'snapshot', 'model', 'location_type', 'sales_dollars']].sort_values('dmand_yr_mo'))
    fig = go.Figure()
    fig =  make_subplots(rows=2, cols=1)

                        x= df_table["snapshot"], 
                        row=1, col=1))
                #  color="model", barmode="group", title = "MAPE by Snapshot")
                        x= df_table["snapshot"], 
                        row=2, col=1))
    return fig

I initially based my code off the following post: [initial post](python 3.x - Sharing same legends for subplots in plotly - Stack Overflow)

Did you import like this?

from plotly.subplots import make_subplots

Yes, that is how I imported the function.

you need to use the upper case: go.Bar()

Thank you. That now throws this:

Traceback (most recent call last)
File "/root/workspace/pages/", line 302, in time_series_show_snapshot
row=1, col=1))
File "/app/.heroku/python/lib/python3.7/site-packages/plotly/graph_objs/", line 3285, in __init__
self._process_kwargs(**dict(arg, **kwargs))
File "/app/.heroku/python/lib/python3.7/site-packages/plotly/", line 4369, in _process_kwargs
raise err
ValueError: Invalid property specified for object of type plotly.graph_objs.Bar: 'row'

Did you mean "dx"?

I tried changing “x” to “dx” and go the following:

Traceback (most recent call last):
  File "/root/workspace/pages/", line 302, in time_series_show_snapshot
    row=1, col=1))
  File "/app/.heroku/python/lib/python3.7/site-packages/plotly/graph_objs/", line 3019, in __init__
    self["dx"] = _v
  File "/app/.heroku/python/lib/python3.7/site-packages/plotly/", line 4851, in __setitem__
    self._set_prop(prop, value)
  File "/app/.heroku/python/lib/python3.7/site-packages/plotly/", line 5195, in _set_prop
    raise err
  File "/app/.heroku/python/lib/python3.7/site-packages/plotly/", line 5190, in _set_prop
    val = validator.validate_coerce(val)
  File "/app/.heroku/python/lib/python3.7/site-packages/_plotly_utils/", line 799, in validate_coerce
  File "/app/.heroku/python/lib/python3.7/site-packages/_plotly_utils/", line 298, in raise_invalid_val
    Invalid value of type 'pandas.core.series.Series' received for the 'dx' property of bar
        Received value: 0      2020-12-31
1      2021-01-31
2      2021-02-28
3      2021-03-31
4      2021-04-30
156    2022-06-30
157    2022-07-31
158    2022-08-31
159    2022-09-30
160    2022-10-31
Name: snapshot, Length: 161, dtype: object

    The 'dx' property is a number and may be specified as:
      - An int or float

this has to be outside of the go.Bar()

Thank you. This was helpful. Now to figure out how to use a column as a color since it’s apparently different than using plotly express.