X-axis labels for histograms and violins

I have three classes that I want to visualize as a violin plot. I have data as an array or arrays. And names as an array of strings. I want the names to be shown on the x-axis.

using StatPlots
gr()
x = [rand(9) for i in 1:3]
lbls = [randstring(2) for i in 1:3]
violin(lbls, x)

This does not seem to work.

violin(x, labels=lbls)

This puts the labels in a legend, but I want it to be along the x-axis. How do I do this without invoking DataFrames, or even with invoking them, but I have many more than three classes of data. Thanks.

Figured it out. The labels need to be a row vector! However

lbls = [randstring(2) for i in 1:3]'

does not work in 0.6 :grimacing:
But that does not relate to plots.

Yes - people felt that transposing should be disallowed for non-numeric matrices. You can use permutedims instead.

2 Likes