Barplot in Julia


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 | Julia | Plotly

The data can be downloaded here: Years of fossil fuel reserves left - Our World in Data

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

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?

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

Give this a go:

using PlotlyJS
using CSV
using DataFrames

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

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

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

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