Plotly plots not showing up?

Viewed 768

I am working with plotly for the first time and when I am running my code snippets the figure is appearing my variables as a variable but no where is the plot showing up???? I am aware this is probably a stupid user error on my part but here I am. Since its not working with my df, I decided to revert back to examples given with documentation associated with plotly. Please tell me what I am doing wrong.

My input (just as in the documentation):

[IN]:
# don't know in a I need this?
import dash

import plotly.express as px
long_df = px.data.medals_long()
long_df

import plotly.express as px
long_df = px.data.medals_long()

fig = px.bar(long_df, x="nation", y="count", color="medal", title="Long-Form Input")
fig.show()

[OUT]: nothing in console, nothing in plots, but this show's up in variables:

print(fig)

I then tried:

[IN]:
print(fig)

[OUT]: 
Figure({
    'data': [{'alignmentgroup': 'True',
              'hovertemplate': 'medal=gold<br>nation=%{x}<br>count=%{y}<extra></extra>',
              'legendgroup': 'gold',
              'marker': {'color': '#636efa'},
              'name': 'gold',
              'offsetgroup': 'gold',
              'orientation': 'v',
              'showlegend': True,
              'textposition': 'auto',
              'type': 'bar',
              'x': array(['South Korea', 'China', 'Canada'], dtype=object),
              'xaxis': 'x',
              'y': array([24, 10,  9], dtype=int64),
              'yaxis': 'y'},
             {'alignmentgroup': 'True',
              'hovertemplate': 'medal=silver<br>nation=%{x}<br>count=%{y}<extra></extra>',
              'legendgroup': 'silver',
              'marker': {'color': '#EF553B'},
              'name': 'silver',
              'offsetgroup': 'silver',
              'orientation': 'v',
              'showlegend': True,
              'textposition': 'auto',
              'type': 'bar',
              'x': array(['South Korea', 'China', 'Canada'], dtype=object),
              'xaxis': 'x',
              'y': array([13, 15, 12], dtype=int64),
              'yaxis': 'y'},
             {'alignmentgroup': 'True',
              'hovertemplate': 'medal=bronze<br>nation=%{x}<br>count=%{y}<extra></extra>',
              'legendgroup': 'bronze',
              'marker': {'color': '#00cc96'},
              'name': 'bronze',
              'offsetgroup': 'bronze',
              'orientation': 'v',
              'showlegend': True,
              'textposition': 'auto',
              'type': 'bar',
              'x': array(['South Korea', 'China', 'Canada'], dtype=object),
              'xaxis': 'x',
              'y': array([11,  8, 12], dtype=int64),
              'yaxis': 'y'}],
    'layout': {'barmode': 'relative',
               'legend': {'title': {'text': 'medal'}, 'tracegroupgap': 0},
               'template': '...',
               'title': {'text': 'Long-Form Input'},
               'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': 'nation'}},
               'yaxis': {'anchor': 'x', 'domain': [0.0, 1.0], 'title': {'text': 'count'}}}
})
Exception in comms call get_value:

  File "C:\Users\cyrra\anaconda3\lib\site-packages\spyder_kernels\comms\commbase.py", line 344, in _handle_remote_call
    self._set_call_return_value(msg_dict, return_value)

  File "C:\Users\cyrra\anaconda3\lib\site-packages\spyder_kernels\comms\commbase.py", line 381, in _set_call_return_value
    self._send_message('remote_call_reply', content=content, data=data,

  File "C:\Users\cyrra\anaconda3\lib\site-packages\spyder_kernels\comms\commbase.py", line 244, in _send_message
    buffers = [cloudpickle.dumps(

  File "C:\Users\cyrra\anaconda3\lib\site-packages\cloudpickle\cloudpickle_fast.py", line 73, in dumps
    cp.dump(obj)

  File "C:\Users\cyrra\anaconda3\lib\site-packages\cloudpickle\cloudpickle_fast.py", line 563, in dump
    return Pickler.dump(self, obj)

TypeError: cannot pickle '_thread.lock' object

Can someone please tell me what is going on or what dumb mistake I am making. I believe I have properly installed dash and plotly via conda.

Thank you,

Rachel

0 Answers
Related