How do I plot data from a dictionary?

Hello there.

I’m trying to plot some data from a dictionary like this:

Dict{Any, Any} with 7 entries:
  "C"                   => 13.3147
  "C ffast-math"        => 8.47802
  "Python- Built-in"    => 1937.68
  "Python numpy"        => 4.6551
  "Python hand-written" => 2512.43
  "Julia built-in"      => 4.58879
  "Julia hand-written"  => 12.8829

I’m using the following piece of code:

 p = plot()
x = 0:length(d)
for k ∈ keys(d)
    scatter!(x,d[k])
end

i’m not necessarily trying to scatter plot, it would be better for me to draw a horizontal bar plot, but I have no idea how to do that.

Using Plots, you can try this:

bar(collect(keys(d)), collect(values(d)), orientation=:horizontal)

or using splatting instead:

bar([keys(d)...], [values(d)...], orientation = :horizontal)
1 Like