### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: Violin plot  (Read 1109 times)

#### apeoperaio

• Full Member
• Posts: 216
##### Violin plot
« on: April 30, 2021, 12:09:15 pm »
Hi all,
I would like to know if there is a way to generate violin plots using TAChart
Violin plot are very informative, much more than simple box and whiskers plots.
See violin plots example and usage here:

Thank you,
Andrea

#### wp

• Hero Member
• Posts: 8568
##### Re: Violin plot
« Reply #1 on: April 30, 2021, 04:28:39 pm »
I understand that the violin plots the density function of a distribution. What is the difference between the left and the right part?
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

#### apeoperaio

• Full Member
• Posts: 216
##### Re: Violin plot
« Reply #2 on: April 30, 2021, 05:21:57 pm »
Typically there is no difference between left and right. Violin plots are symmetrical. Anyway they can be used to represent two different distribution, one on the left side and one on the right.
See for example:
https://images.app.goo.gl/EwZtzonAuN8HK5EX9

#### wp

• Hero Member
• Posts: 8568
##### Re: Violin plot
« Reply #3 on: April 30, 2021, 05:38:49 pm »
Yes, that was my opinion, too. but when there is a left and a right distribution, to what does the Box-Whisker plot refer?

Anyway, in the attachment you find a solution based on two AreaSeries showing the same distribution on the left and right side (just a quick test - it can be optimized, I'm sure), and an overlay BoxAndWhisker series showing the 1%, 25%, 50%, 75% and 99% percentiles.

So you see: there is not dedicated ViolinSeries, but it can be composed by other series rather easily. Most of the work is needed by the math to calculate the distribution.
« Last Edit: April 30, 2021, 05:44:11 pm by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

#### apeoperaio

• Full Member
• Posts: 216
##### Re: Violin plot
« Reply #4 on: May 03, 2021, 10:57:41 am »
Thank you very much for the project!
I suppose that when there is a left and a right distribution, two Box-Whiskers plot are drawn. On the right half Box-Whiskers is drawn referring to the right distribution and another half Box-Whiskers plot is drawn on the left side referring to the left distribution.