How can I plot bar chart in Julia?

Viewed 2916
plot(Giorni,Fatturato, label="line")
scatter!( Giorni,Fatturato, label="points")
ylabel!("Fatturato [Dollari]")
xlabel!("Tempo (Giorni)")
title!("Fatturato Giornaliero")

With this I obtain a normal graph, how can i plot a bar chart?

2 Answers

I guess you are looking for Plots.bar function. The code below produces the following plot barplot fatturato giornaliero

using Plots
giorni = collect(1:10)
fatturato = rand(10)
p = bar(giorni,fatturato)
ylabel!("Fatturato [Dollari]")
xlabel!("Tempo (Giorni)")
title!("Fatturato Giornaliero")
savefig(p,"barplot.png")

You can obtain barchart via bar! or histogram! depending what exactly you want to achieve. For an example:


using Plots
giorni = rand(50) .+ (0.8:0.8:40)
fatturato = giorni .+ rand(50)

plot(giorni,fatturato, label="line")
scatter!( giorni,fatturato, label="points")
ylabel!("Fatturato [Dollari]")
xlabel!("Tempo (Giorni)")
title!("Fatturato Giornaliero")
histogram!(giorni,label="giorni",bins=20)
histogram!(fatturato,label="fatturato",bins=20, orientation=:horizontal)

It is not clear however what you exactly have in mind so this is just an example.

enter image description here

Related