I would like to create a bar chart that shows negative values of different color from positive values. I created a very simple example using x = 6 discrete time periods and y = 6 financial payoffs (2 of which are negative).
I attempted to specify a color for each financial payoff; this failed. What happened instead is that it took the first color and applied it to all 6 payoffs as opposed to applying each color to each payoff in sequence.
The simple plot code I am using is as follows (done within a Pluto notebook):
using Plots
x = 1:6 # This is a simple index across time periods 1 through 6.
y = [-50, -25, 0, 25, 50, 100] # this shows financial payoffs for time periods 1 through 6.
colors = [“#db5a44”, “#db5a44”, “#447adb”, “#447adb”, “#447adb”, “#447adb”]
plot(x, y, seriestype = :bar, legend=false, size=(800,500), palette = colors)
What is the suggested way to introduce conditional coloring to the bar chart data, keeping it as simple as possible using only the Plots.jl package?