How to show all xlabels in violin plot

Hi,

In the code below, only evenly indexed labels display. How do I show all xlabels?

Thanks!


using StatsPlots
x = randn(1000, 16)
labels = map(x -> randstring(3), 1:16)
violin(permutedims(labels), x, rotation = 90, leg = false)

You could also use the Plots’ keyword: xticks=:all on your original code.

1 Like

Thanks Rafael. I updated the solution above. Even when I figure out a solution, you find a better one :slightly_smiling_face:.

1 Like

Hum… That was supposed to work with the code in your original post.

PS:
labels are not used in your revised solution. Also, I am surprised that :all works as you wish in that snippet?

Opps. You are correct. I posted the wrong syntax. Can you clarify the syntax with :all. The following does not work:

using StatsPlots
using Random

x = randn(1000, 16)
labels = map(x -> randstring(3), 1:16)
violin(x, xticks = (:all,labels), rotation = 90, leg = false)

So, from the discussion above, I see two options:

using StatsPlots, Random

x = randn(1000, 16)
labels = map(x -> randstring(3), 1:16)

# OPTION-1
violin(permutedims(labels), x, xticks=:all, rotation=45, leg=false)

# OPTION-2
violin(x, xticks=(1:16, labels), rotation=45, leg=false)
1 Like