I need to plot a stacked bar chart from a nested dictionary using matplotlib. I know to plot it by converting it into a dataframe and then calling the plot function. What I need to know is how I can plot it without converting it into a dataframe i.e., without using pandas or numpy or any other module or library. I would like to create stacked bar chart by using for loop over a nested dictionary. My dictionary and code attempt are below. I would also like to know how I can name each section of the bar chart while creating it.
pop_data = {'Bengaluru': {2016: 2000000, 2017: 3000000, 2018: 4000000}, 'Mumbai': {2016: 5000000, 2017: 6000000, 2018: 7000000}, 'Tokyo': {2016: 8000000, 2017: 9000000, 2018: 10000000}}
sortedList = sorted(pop_data.items())
for data in sortedList:
city = data[0]
population = data[1]
for year,pop in population.items():
plt.bar(city, pop)
plt.show()