I want to use a dictionary to create a plot.
import matplotlib.pyplot as plt
data = {"rdeca":"4",
"zelena":"5",
"rumena":"7",
"modra":"2",
"roza": "9"}
colors = {"rdeca":"red",
"zelena":"green",
"modra":"blue",
"roza":"pink",
"rumena":"yellow"}
plt.bar(range(len(data)), list(data.values()), align='center') #This is what I use to plot a bar plot with the `data` dictionary
plt.xticks(range(len(data)), list(data.keys()))
plt.show()
What I want to achieve is to use the colors dict to assign a color to each bar in the bar plot. As you can see the data key "rdeca" should use the color "red" etc. I am trying to achieve this with color = colors.get() in the plt.bar arguments. I wasn't successful yet. I got it to use the colors but just in the order as they are in the colors dictionary. Not corresponding to the data dictionary


