Plotly Bar Chart Title Issues

Viewed 570

This seems like a very easy thing to do but I am unsure what I'm missing. All I'm trying to do is add a title to my plotly chart.

from plotly.graph_objs import Bar

tuesday_plot_div = plot([Bar(title="Tuesday Data", x=['Win', "Lose"], y=[len(tuesday_wins), len(tuesday_losses)],
                              opacity=0.8)],
                         output_type='div')

I receive an error in the editor

Expected type "dict", got "str" instead

When I try to display that in my html

Invalid property specified for object of type plotly.graph_objs.Bar: 'title'
1 Answers

After searching more and more I had to adjust some of the code to the following.

import plotly.graph_objs as go

trace = go.Bar(x=['Win', 'Lose'], y=[len(tuesday_wins), len(tuesday_losses)])

testing1 = {'title': 'Here we are'}
fig = go.Figure(data=trace, layout=testing1)
final2 = plot(fig, output_type='div')
Related