# Plot from DataFrames using StatsPlots

**URL:** <https://discourse.julialang.org/t/plot-from-dataframes-using-statsplots/83991>\
**Category:** General Usage\
**Tags:** statsplots\
**Created:** [July 9, 2022, 3:25pm UTC](https://discourse.julialang.org/t/plot-from-dataframes-using-statsplots/83991 "2022-07-09T15:25:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [July 9, 2022, 3:25pm UTC](https://discourse.julialang.org/t/plot-from-dataframes-using-statsplots/83991/1 "2022-07-09T15:25:37Z")

</div>

Hi all,

I just learn about using csv and create dataframe. This is my code:

```julia
using CSV
using DataFrames

df = CSV.read("/home/browni/LasthrimProjection/importedenergydata.csv", DataFrame)
print(df)

```

![Capture d’écran_2022-07-09_22-25-57](https://global.discourse-cdn.com/julialang/original/3X/e/e/ee5a6641e66301ccf2aa8f8ee5ce4ae5678c80e9.png)

Now, I want to plot it like this (the differences are setosa will be coal, versicolor will be oil, and virginica will be natural gas) and each group represent the country, if possible can I add custom marker like the country flag in circle?

 ![Capture d’écran_2022-07-09_22-21-51](https://global.discourse-cdn.com/julialang/original/3X/4/c/4ca8b0e761c4d69ec447ade36f5416c1675eada7.png)

I read this:  
[https://github.com/JuliaPlots/StatsPlots.jl](https://github.com/JuliaPlots/StatsPlots.jl)

But, after reading that, I still have no idea how to create the plot…

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [July 9, 2022, 5:56pm UTC](https://discourse.julialang.org/t/plot-from-dataframes-using-statsplots/83991/2 "2022-07-09T17:56:53Z")

</div>

You can try this:

```julia
using StatsPlots
@df df groupedbar(:Country, :Percentage, group=:Energy, ylabel="Percentage", bar_width=0.7, legend=:outertopright)

```
