# Barplot in Julia

**URL:** <https://discourse.julialang.org/t/barplot-in-julia/70982>\
**Category:** New to Julia\
**Tags:** plotting, dataframes, csv, plotlyjs\
**Created:** [November 4, 2021, 11:57pm UTC](https://discourse.julialang.org/t/barplot-in-julia/70982 "2021-11-04T23:57:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dadaforpeace](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@dadaforpeace](https://discourse.julialang.org/u/dadaforpeace)\
**Post date:** [November 4, 2021, 11:57pm UTC](https://discourse.julialang.org/t/barplot-in-julia/70982/1 "2021-11-04T23:57:14Z")

</div>

Hi,

I would like to make a really simple Bar Plot, but the Data especially the Name of a Column is quite long and thus for me impossible to address. I am following the following instructions: [Bar charts in Julia](https://plotly.com/julia/bar-charts/)

The data can be downloaded here: [Years of fossil fuel reserves left - Our World in Data](https://ourworldindata.org/grapher/years-of-fossil-fuel-reserves-left?country=Natural+Gas~Oil~Coal)

I am working with the following file: years-of-fossil-fuel-reserves-left.csv and here is the code which does not work.

```julia
using PlotlyJS
using CSV
using DataFrames

df_1 = DataFrame(CSV.File("years-of-fossil-fuel-reserves-left.csv"))

plot(df_1, x=:Entity, y=:"Reserves-Production Ratio (BP Statistics (2016))", kind="bar")

```

I get the following error: “Cannot convert DataFrame to series data for plotting”

I tried a couple of things to address the column Reserves-Production Ratio (BP Statistics (2016)) without success. Can anyone help?

---

<div class="post-metadata">

**Author:** ![George9000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/george9000/32/23619_2.png) [@George9000](https://discourse.julialang.org/u/George9000)\
**Post date:** [November 5, 2021, 3:09am UTC](https://discourse.julialang.org/t/barplot-in-julia/70982/2 "2021-11-05T03:09:05Z")

</div>

I suspect you ran into trouble with the spaces in the y-column name and the use of double quotes to compensate. Try the `normalizenames = true` option of `CSV.read`.

Give this a go:

```julia
using PlotlyJS
using CSV
using DataFrames

fuel = CSV.read("./years-of-fossil-fuel-reserves-left.csv", DataFrame; normalizenames = true)

plot(fuel, x = :Entity, y = :Reserves_Production_Ratio_BP_Statistics_2016_, kind = "bar")

## Horizontal
plot(bar(fuel,
         y = :Entity,
         x = :Reserves_Production_Ratio_BP_Statistics_2016_,
         orientation = "h"),
     Layout(title="Years of fossil fuel reserves left",
            yaxis_title = "Type",
            xaxis_title = "Years of production left(based on 2015 production & known reserves)"))

```

---

<div class="post-metadata">

**Author:** ![dadaforpeace](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@dadaforpeace](https://discourse.julialang.org/u/dadaforpeace)\
**Post date:** [November 5, 2021, 9:34am UTC](https://discourse.julialang.org/t/barplot-in-julia/70982/3 "2021-11-05T09:34:32Z")

</div>

Thank you very much. The normalization of the names was a great idea 🙂
