Dear all,
I have set the color of bar to red
,but I always get the color of grey. What’s wrong with this problem?
using DataFrames
using CSV
using Plots
using PlotThemes
df = DataFrame(CSV.File("gdp.csv", header=true))
sort!(df, :Year)
theme(:dark)
p = bar(df.Year, zeros(nrow(df)), ylim=(0, maximum(df.GDP)),
leg=false, xlabel="Year", ylabel="GDP", c=:white)
anim = Animation()
for x in range(1, nrow(df), step=1)
bar!(p, [df.Year[x]], [df.GDP[x]], c = :red)
frame(anim)
end
gif(anim, "gdp.gif", fps = 15)
The correct argument is color
, not c
.
bar!(p, [df.Year[x]], [df.GDP[x]], color = :red)
It does not work. The color is still grey.
Humpf. I got one glorious all red plot the first time I tried. Now I get one red bar and the rest white with either c
or color
.
What versions are you using?
(dfenv) pkg> st
Status `~/Desktop/Julia/dfenv/Project.toml`
[336ed68f] CSV v0.10.4
[a93c6f00] DataFrames v1.3.4
[ccf2f8ad] PlotThemes v3.0.0
[91a5bcdd] Plots v1.29.0
Plotting one at a time in the REPL gets the correct red bars, using @animate
or frame
like this example always results in a .gif with the first bar red and the rest white. I am stumped, sorry.
The problem is solved. Maybe it’s the problem of Vscode. Now It display the correct color. Thanks for your help.