Fixing a Plotly figure
Your colleague had started a project to create a visualization of sales for the first three months of 2020. However, she then left for some annual leave - but the boss wants the visualization now!
You can see she left behind a dictionary object that has started to define the visualization. It is your task to finish this dictionary with the important key arguments so it can be turned into a Plotly visualization.
In the exercises where it is needed throughout the course, plotly.graph_objects
has already been loaded as go
.
There is a monthly_sales
dictionary that has been partially complete also available.
This exercise is part of the course
Introduction to Data Visualization with Plotly in Python
Exercise instructions
- Examine the
monthly_sales
dictionary that has been printed in the console to determine what is missing. - Update the
type
inside thedata
element ofmonthly_sales
to be abar
chart. - Update the
text
element of thetitle
of thelayout
element to be'Sales for Jan-Mar 2020'
. - Create a figure using
go.Figure()
and themonthly_sales
dictionary.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Examine the printed dictionary
# Update the type
monthly_sales['data'][0][____] = ____
# Update the title text
monthly_sales[____][____]['text'] = 'Sales for Jan-Mar 2020'
# Create a figure
fig = go.____(____)
# Print it out!
fig.show()