I need some help plotting my data. Is there a way to plot a bar graph with different colors. For example I would like to have a legend showing a green dot with the text positive and red dot with the text negative. Furthermore, if the graph value falls below 0 add a red color. If it is above 0 add a green color? Is this possible? Any help in the right direction would be greatly appreciated.
Is it possible?
See my code below:
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
df = pd.DataFrame({'Years': ['2015', '2016', '2017', '2018'],
'Value': [-495982.0, 405549.0, -351541.0, 283790.0]})
values = df["Value"]
values = values / 1e3
asOfDates = df['Years']
Value = df['Value']/100
fig, ax = plt.subplots()
ax.set_title('Plotting Financials')
ax.set_xlabel('Years')
ax.set_ylabel('value')
plt.bar(asOfDates,values)
ax.get_yaxis().set_major_formatter(matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x), ',')))
plt.show()