ViolinPlot

New in version 5.0

ViolinPlot ( appearanceConst ;​ seriesGap ;​ proportionalSeries ;​ centerLineStroke ;​ centerLineColor ;​ centerLineLocation ;​ sideFlag )

Argument Type Range Default Note
appearanceConst int 0..127 default
seriesGap num 0..1000 100 In % of series width
proportionalSeries int 0..1 0
centerLineStroke num 0..1000 1
centerLineColor rgba 0..255 lightGray
centerLineLocation int 0..1 0 0...back, 1...front
sideFlag int 0..3 0 v5.0.6 or higher required
Examples
Description

Violin plots are used to represent statistical distributions. The 1st argument appearanceConstants makes it possible to rotate the chart 90 degrees (appearanceConstants = horizontal) and to add shadow (appearanceConstants = shadow) to the plots. Appearance constants can be combined by using a plus sign "+". The fills, borders and shadows can be varied by using the style functions FillColorScheme() , FillStyle() , BorderColorScheme() , BorderStyle() and ShadowStyle() .

VIOLIN_PLOT_01
1

OpenDrawing(250;​120)

2

ChartData(1 1.5 8 9.5 4.5 7.2 3.3 4 5 3.1 3.1 9 3 6)

3

ViolinPlot()

4

/* Set up styles. */

5

BorderStyle(1;​none)

6

FillStyle(1;​#f003)

7

/* Set up axes. */

8

AxisLine(all;​0)

9

AxisMajorTicks(all;​0)

10

/* Set up grid. */

11

MajorGridLineColors(x;​y;​#ccc)

12

MajorGridLineWidths(x;​y;​0.25)

13

MajorGridLineWidths(y;​x;​0)

14

CloseDrawing()

VIOLIN_PLOT_01

By using the argument seriesGap the space between distributions can be controlled. The argument is to be entered in percent of the series width. As the default, the space between two distributions is exactly one series width, i.e. seriesGap =​ 100. The argument proportionalSeries is useful for comparing distributions. By defining proportionalSeries =​ on the distribution scale is identical for all distributions and does not depend on the value range of each individual distribution. The stroke and color of an optional center line can be controlled by using the arguments centerLineStroke and centerLineColor. By using centerLineLocation =​ 1 the center line can be positioned in the foreground.
By using the argument sideFlag the arrangement of the distributions can be controlled.
sideFlag =​ 0: The distributions are drawn symmetrically (default).
sideFlag =​ 1: The distributions are drawn only left of the center line (or above the center line if the plot is horizontal).
sideFlag =​ 2: The distributions are drawn only right of the center line (or below the center line if the plot is horizontal).
sideFlag =​ 3: The distribution of value series i is drawn on the left, the distribution of value series i+1 is drawn on the right.

VIOLIN_PLOT_02
1

OpenDrawing(250;​120)

2

ChartData(1 9.1 9.5 1.5 8 4.5 7.2 3.3 4 5 3.1 3.1 9 3 6 9.2)

3

ViolinPlot(horizontal;​;​;​0.25;​red)

4

/* Set up styles. */

5

BorderStyle(1;​none)

6

FillStyle(1;​#f003)

7

/* Set up axes. */

8

Scaling(x;​linear;​0;​10;​5)

9

AxisLine(all;​0)

10

AxisMajorTicks(all;​0)

11

/* Set up grid. */

12

MajorGridLineWidths(x;​y;​0)

13

MajorGridLineWidths(y;​x;​0.25)

14

MajorGridLineColors(y;​x;​#ccc)

15

CloseDrawing()

VIOLIN_PLOT_02
VIOLIN_PLOT_03
1

OpenDrawing(250;​120)

2

ChartData(1 9.1 9.5 1.5 8 4.5 7.2 3.3 4 5 3.1 3.1 9 3 6 9.2;​

3

1 8.5 8 9.5 8.5 7.2 8.3 4 5 8.1 3.1 9 8 6)

4

ViolinPlot(horizontal;​50;​0;​0.25;​gray)

5

/* Set up styles. */

6

BorderStyle(all;​none)

7

FillStyle(1;​#f003)

8

FillStyle(2;​#00f3)

9

/* Set up axes. */

10

Scaling(x;​linear;​0;​10;​5)

11

ScalingOptions(y;​on)

12

AxisLine(all;​0)

13

AxisMajorTicks(all;​0)

14

AxisMajorTickLabelTexts(x;​"";​"|u|";​"|u|";​"|u|";​"|u|")

15

/* Set up grid. */

16

MajorGridLineWidths(x;​y;​0)

17

MajorGridLineWidths(y;​x;​0;​0.25;​0.25;​0.25;​0.25)

18

MajorGridLineColors(y;​x;​#ccc)

19

CloseDrawing()

VIOLIN_PLOT_03
VIOLIN_PLOT_04
1

OpenDrawing(400;​260)

2

OpenChart(60;​20;​300;​200;​on)

3

ChartData(

4

94 94 97 96 99 95 83 95 93 89 92 98 62 86 99 96 99 98 96 97 88 94 100 97 90 97 93 96 84 78 100 97 100 86 89 95 98 97 80 97 98 87 91 95 84 97;​

5

83 77 86 86 78 87 67 74 81 90 84 72 68 79 87 81 68 75 90 73 81 75 77 93 74 81 81 77 90 73 77 80 76 87 82 81 91 83 71 91 78 82 78 90 76 74;​

6

66 52 82 78 67 81 79 75 63 64 78 89 59 52 5 86 73 82 77 50 58 85 87 70 78 49 62 77 49 60 58 82 50 50 62 73 70 47 71 86 91 67 68 98 93 55;​

7

67 74 75 73 71 73 39 72 65 74 58 76 62 70 73 68 66 64 80 75 80 69 83 85 63 67 73 89 64 67 70 68 73 59 92 79 90 88 82 89 58 69 71 71 66 62;​

8

52 52 48 50 50 52 44 51 48 52 48 52 50 49 50 52 48 48 52 49 52 51 51 48 50 48 51 48 48 49 51 51 50 49 41 52 51 50 51 47 51 45 51 52 52 47;​

9

21 6 18 19 5 4 18 21 16 18 22 16 8 12 100 15 14 10 25 24 19 7 2 16 18 11 14 12 9 27 14 20 3 20 4 10 6 18 12 14 4 10 7 9 26 19;​

10

27 7 13 15 10 20 29 12 12 25 14 6 17 7 36 8 5 39 8 12 7 15 6 12 20 3 11 3 14 28 15 13 4 32 29 3 8 13 8 12 14 20 12 6 8 14;​

11

5 7 0 1 1 2 8 2 7 11 13 1 5 3 96 2 1 2 3 7 6 5 7 2 2 4 4 2 1 9 0 9 2 4 4 1 1 7 1 3 1 6 3 3 2 7)

12

ViolinPlot(horizontal;​100;​0;​0.25;​#ddd)

13

/* Set up styles. */

14

BorderStyle(all;​none)

15

FillColorScheme(15;​solid;​0.75)

16

ScalingOptions(y;​on) /* Reverse y-axis. */

17

/* Set up axes. */

18

Scaling(x;​linear;​0;​100;​4)

19

AxisLine(all;​0)

20

AxisMajorTicks(all;​0)

21

AxisMajorTickLabelStyle(x;​Verdana;​10;​plain;​#555)

22

AxisMajorTickLabelTexts(x;​"|u|%")

23

AxisMajorTickLabelTexts(y;​"Q-1";​"Q-2";​"Q-3";​"Q-4";​"Q-5";​"Q-6";​"Q-7";​"Q-8")

24

AxisMajorTickLabelStyle(y;​Verdana;​10;​plain;​#555)

25

AxisMajorTickLabelOptions(y;​;​-10)

26

/* Set up grid. */

27

MajorGridLineColors(x;​y;​none)

28

MajorGridLineColors(y;​x;​#ccc)

29

MajorGridLineWidths(y;​x;​0.25)

30

CloseChart()

31

CloseDrawing()

VIOLIN_PLOT_04
VIOLIN_PLOT_05
1

OpenDrawing(300;​200)

2

OpenChart(60;​20;​220;​150;​on)

3

ChartData(

4

94 94 97 96 99 95 83 95 93 89 92 98 62 86 99 96 99 98 96 97 88 94 100 97 90 97 93 96 84 78 100 97 100 86 89 95 98 97 80 97 98 87 91 95 84 97;​

5

83 77 86 86 78 87 67 74 81 90 84 72 68 79 87 81 68 75 90 73 81 75 77 93 74 81 81 77 90 73 77 80 76 87 82 81 91 83 71 91 78 82 78 90 76 74;​

6

66 52 82 78 67 81 79 75 63 64 78 89 59 52 5 86 73 82 77 50 58 85 87 70 78 49 62 77 49 60 58 82 50 50 62 73 70 47 71 86 91 67 68 98 93 55;​

7

67 74 75 73 71 73 39 72 65 74 58 76 62 70 73 68 66 64 80 75 80 69 83 85 63 67 73 89 64 67 70 68 73 59 92 79 90 88 82 89 58 69 71 71 66 62)

8

ViolinPlot(horizontal+shadow;​100;​0;​0.25;​#ddd;​;​3)

9

/* Set up styles. */

10

BorderStyle(all;​none)

11

FillStyle(1;​#005ca988)

12

FillStyle(2;​#96b05f88)

13

FillStyle(3;​#005ca988)

14

FillStyle(4;​#96b05f88)

15

ShadowStyle(all;​1 1 3;​lightGray)

16

/* Set up axes. */

17

Scaling(x;​linear;​0;​100;​4)

18

ScalingOptions(y;​on) /* Reverse y-axis. */

19

AxisLine(all;​0)

20

AxisMajorTicks(all;​0)

21

AxisMajorTickLabelStyle(x;​Verdana;​10;​plain;​#555)

22

AxisMajorTickLabelTexts(x;​"|u|%")

23

AxisMajorTickLabelTexts(y;​"D-1/2";​"D-3/4")

24

AxisMajorTickLabelStyle(y;​Verdana;​10;​plain;​#555)

25

AxisMajorTickLabelOptions(y;​;​-10)

26

/* Set up grid. */

27

MajorGridLineColors(x;​y;​none)

28

MajorGridLineColors(y;​x;​#ddd)

29

MajorGridLineWidths(y;​x;​0.25)

30

CloseChart()

31

CloseDrawing()

VIOLIN_PLOT_05
Scroll to Top