@VivMendes I think I can do it in a more efficient way.
Notice that according to the documentation you have just mentioned, multi-category axis charts can be only achieved using raw arrays and not DataFrames.
In fact, we cannot pass a vector of symbols to the x or the y kwargs inside the Plot() function to have two categories in one axis.
But you can always work with the columns of the DataFrame as arrays.
Here is my suggestion:
Plot(
[bar(;
x = [longdf.Year, longdf.Levels],
y = filter(:Status => x -> x == "NotinLF",longdf).Percent,
name = "Not in the Labor Force"),
bar(;
x = [longdf.Year, longdf.Levels],
y = filter(:Status => x -> x == "Unemployment",longdf).Percent,
name = "Unemployed"),
bar(;
x = [longdf.Year, longdf.Levels],
y = filter(:Status => x -> x == "Employment",longdf).Percent,
name = "Employed")],
Layout(
barmode="stack",
height = 600
)
)
Here is what I get:
And if you want them horizontal:
Plot(
[bar(;
x = filter(:Status => x -> x == "NotinLF",longdf).Percent,
y = [longdf.Year, longdf.Levels],
name = "Not in the Labor Force",
orientation = "h"),
bar(;
x = filter(:Status => x -> x == "Unemployment",longdf).Percent,
y = [longdf.Year, longdf.Levels],
name = "Unemployed",
orientation = "h"),
bar(;
x = filter(:Status => x -> x == "Employment",longdf).Percent,
y = [longdf.Year, longdf.Levels],
name = "Employed",
orientation = "h")],
Layout(
barmode="stack",
height = 600
)
)
I have converted the values in column Year to strings, to make sure Plotly does not mess-up with dates.
Depending on your goal, it may also be wise to store in different variables the subsets of the DataFrame that you want to use later according to the :Status.
But let us wait for @empet, since she always has clever solutions. ![]()

