create nested pie charts from two dictionaries using matplotlib and numpy

Assuming that you only have single value for each key, you can extract a list this way.

dict_to_array = lambda x:np.array([value for _,value in x.items()])
In [11]: labor_arr = dict_to_array(labour_cost_dict)
Out[11]: [240, 3, 400]
In [29]: final_arr = np.vstack((labour_arr, mat_arr))

In [30]: final_arr
Out[30]: 
array([[240,   3, 400],
       [100,  13,  20]])


And then you can convert them to np array and plot the pie chart. Since its not exactly clear how you want your pie chart to be, you can plot using the example provided

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top