Enrico Cipolla
Enrico Cipolla

Reputation: 71

How can I plot bar chart in Julia?

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?

Upvotes: 7

Views: 8989

Answers (2)

Alessandro
Alessandro

Reputation: 161

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")

Upvotes: 7

Przemyslaw Szufel
Przemyslaw Szufel

Reputation: 42214

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

Upvotes: 5

Related Questions