Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dash problems
#1
I want to scatter plot campcnt vs cnt by year, but I get error msg. How to fix this problem?
Thanks,
Jeff
print(df.head())


app = dash.Dash()
app.layout = html.Div([
    dcc.Graph(
        id='life-exp-vs-gdp',
        figure={
            'data': [
                go.Scatter(
                    x=df[df['year'] == i]['cntcamp'],
                    y=df[df['year'] == i]['cnt'],
                    mode='markers',
                    opacity=0.7,
                    marker={
                        'size': 15,
                        'line': {'width': 0.5, 'color': 'white'}
                    },
                    name=i
                ) for i in df.year.unique()
            ],
            'layout': go.Layout(
                xaxis={'type': 'log', 'title': 'Camp Count'},
                yaxis={'title': 'Total count'},
                margin={'l': 40, 'b': 40, 't': 10, 'r': 10},
                legend={'x': 0, 'y': 1},
                hovermode='closest'
            )
        }
    )
])
Output:
year cntcamp cnt 0 2015 36 347318781 1 2017 100 115586825 2 2016 48 59420381 3 2018 49 12924098 4 2014 6 2052933
Error:
Traceback (most recent call last): File "<ipython-input-8-ddb45a8148ad>", line 20, in <module> ) for i in df.year.unique() AttributeError: 'SASdata' object has no attribute 'year'
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  create loop of subplot plotly dash without hardcode tonycat 0 3,923 Sep-23-2020, 08:40 AM
Last Post: tonycat
  How to update component props every time when a Dash callback returns? sguzunov 0 2,542 Jul-27-2020, 07:11 AM
Last Post: sguzunov
  Invalid archive error when attempting to install dash bootstrap components meaydemi 0 4,783 Jul-11-2019, 05:49 PM
Last Post: meaydemi
  how to use dataframe in dash? zhujp98 1 2,849 Jun-20-2018, 12:19 AM
Last Post: scidam
  can not change double to single dash oco 7 4,646 Jun-03-2018, 09:51 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020