# Logarithmic x-axis of violin plots

**URL:** <https://discourse.julialang.org/t/logarithmic-x-axis-of-violin-plots/91065>\
**Category:** Visualization\
**Tags:** plotting, makie, cairo\
**Created:** [November 30, 2022, 8:44pm UTC](https://discourse.julialang.org/t/logarithmic-x-axis-of-violin-plots/91065 "2022-11-30T20:44:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pascal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pascal/32/207922_2.png) [@pascal](https://discourse.julialang.org/u/pascal)\
**Post date:** [November 30, 2022, 8:44pm UTC](https://discourse.julialang.org/t/logarithmic-x-axis-of-violin-plots/91065/1 "2022-11-30T20:44:14Z")

</div>

Hello everyone,

I’d like to plot a violin plot on a log10 x-axis, e.g.:

```julia
using DataFrames, DataFramesMeta, CairoMakie
df = DataFrame(
    x = repeat(10.0 .^ (-1:3), inner=10),
    y = rand(50)
)

fig = Figure()
ax = Axis(fig[1,1], xscale = log10)
violin!(ax, df.x, df.y)
fig

```

This fails because the leftmost violin somehow protrudes into negative x-values before the axis transformation, I guess. And, the width of the violins seem to be constant as well and are also not transformed as can be seen by using `side=:right`.  
Any solution for this?  
Would be nice if this would work out-of-the-box.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [December 1, 2022, 7:28am UTC](https://discourse.julialang.org/t/logarithmic-x-axis-of-violin-plots/91065/2 "2022-12-01T07:28:17Z")

</div>

It’s probably better quality if you don’t transform the violin but log transform the data and then violin that. The problem comes from the violin tails where the kernel extends further than the last data point into the negative values, although there is an attribute which can cut off these ends.

---

<div class="post-metadata">

**Author:** ![pascal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pascal/32/207922_2.png) [@pascal](https://discourse.julialang.org/u/pascal)\
**Post date:** [December 1, 2022, 8:37am UTC](https://discourse.julialang.org/t/logarithmic-x-axis-of-violin-plots/91065/3 "2022-12-01T08:37:35Z")

</div>

Thanks @jules.

The violin tails extend in y direction and I want to log-scale the x-axis. So it shouldn’t be the tails.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [December 1, 2022, 9:20am UTC](https://discourse.julialang.org/t/logarithmic-x-axis-of-violin-plots/91065/4 "2022-12-01T09:20:26Z")

</div>

Oh I see, I have never seen a violin plot with the density part on a log axis. You could also try with `density` and orientation vertical?
