Bar chart with rotated x label for each bar

Try setting xticks manually. I think something like xticks=minimum(df.naics):maximum(df.naics) (assuming that’s the column that provides the x values. Compare:

julia> df = DataFrame(idx=1:20, val = rand(20), label = [randstring(4) for _ in 1:20]);

julia> bar(df.idx, df.val)

julia> bar(df.idx, df.val, legend=false)

to

bar(df.idx, df.val, legend=false, xticks=1:20)

You can also set the labels to be strings:

bar(df.idx, df.val, legend=false, xticks=(1:20, df.label), xrotation=90)

As for centering text, I’m guessing it’s something with xfontvalign or xfonthalign, but I can’t figure it out. And for removing the spaces, take a look at the various framestyles, and I think there are arguments involving margins, but I don’t know for sure. See the bottom of this page for all the attributes you can play with.

Would be nice if the possible arguments for all of those attributes lived somewhere in the docs too.

3 Likes