Error reads:
ValueError:
The ‘specs’ argument to make_subplots must be a 2D list of dictionaries with dimensions (2 x 2).
Received value of type <class ‘list’>: [[{‘type’: ‘domain’}, {‘type’: ‘domain’}, {‘type’: ‘domain’}, {‘type’: ‘domain’}]]
Code is listed below:
import plotly.graph_objects as go
from plotly.subplots import make_subplots
labels = [“5-Strongly Agree”, “4-Agree”, “3-Neutral”, “2-Disagree”, “1-Strongly Disagree”]
Create subplots: use ‘domain’ type for Pie subplot
fig = make_subplots(rows=2, cols=2, specs=[[{‘type’:‘domain’}, {‘type’:‘domain’},
{‘type’:‘domain’}, {‘type’:‘domain’}]])
fig.add_trace(go.Pie(labels=labels, values=[61, 32, 5, 1, 1], name=“The training provided all of the necessary tools and resources needed to increase my knowledge to perform my work efficiently and effectively.”),
1, 1)
fig.add_trace(go.Pie(labels=labels, values=[61, 33, 5, .5, .5], name=“The training materials were relevant and helped me learn the required knowledge and skills.”),
1, 2)
fig.add_trace(go.Pie(labels=labels, values=[62, 32, 5, .5, .5], name=“I will be able to apply the knowledge and skills learned in this training to do my job.”),
2, 1)
fig.add_trace(go.Pie(labels=labels, values=[56, 35, 6, 2, 1], name=“This training provided value and would be beneficial to others.”),
2, 2)
Use hole
to create a donut-like pie chart
fig.update_traces(hole=.4, hoverinfo=“label+percent+name”)
fig.update_layout(
title_text=“Survey Effectiveness Summary”,
# Add annotations in the center of the donut pies.
annotations=[dict(text=‘Question 1:The training provided all the necessary tools…’, x=0.10, y=0.5, font_size=12, showarrow=False),
dict(text=‘Question 2:The training materials were releveant…’, x=0.90, y=0.5, font_size=12, showarrow=False),
dict(text=‘I will be able to apply the knowledge …’ , x=0.10, y=0.5, font_size=20, showarrow=False),
dict(text=‘This training provided value and would be beneficial…’ , x=0.90, y=0.5, font_size=20, showarrow=False)])
fig.show()
I am not sure why I keep getting the same error time after time