8
$\begingroup$

Is there a recommended way to illustrate a heavily skewed distribution using a boxplot? For example, my boxplot looks like so:

enter image description here

It's very difficult to know what the median value is for the green boxplot. If I specify the range using ylim(0, 1), as far as I can tell ggplot2 removes points outside of the range in the boxplot calculation. I'm creating my plot using the following R code:

ggplot(df, aes(x=x, y=y)) + geom_boxplot(aes(colour=status)) 

I am aware that I can plot this using a histogram, but it's difficult to visuallly compare the two groups using a histogram.

$\endgroup$
5
  • 2
    $\begingroup$ What about a qqplot or a relative distribution plot? When the goal is to compare the distributions, it might be better with a plot specially made for distribution comparison, than with two parallell plots. $\endgroup$ Commented Dec 12, 2016 at 10:54
  • 2
    $\begingroup$ Zero-skewed is not a good term for "skewed because there are lots of zeros" as zero skewness otherwise means skewness of zero. But it's not difficult to determine the median on the right at all: it's zero, as clearly at least 75% of values are zero. I'd use a quantile plot for these data. Can you post them? $\endgroup$
    – Nick Cox
    Commented Dec 12, 2016 at 10:56
  • $\begingroup$ @kjetilbhalvorsen - good idea, I have used geom_freqpoly() previously. @nickcox thanks for explaining - did not realize I was using incorrect term. I'll prepare a sample of data to post $\endgroup$
    – celenius
    Commented Dec 12, 2016 at 11:01
  • 1
    $\begingroup$ See stats.stackexchange.com/questions/140090/… for a quantile-box plot for a dataset with several zeros. But your data appear more skewed yet. $\endgroup$
    – Nick Cox
    Commented Dec 12, 2016 at 11:02
  • 1
    $\begingroup$ Independently of other suggestions, using a transformed scale might also help, say cube root or square root. $\endgroup$
    – Nick Cox
    Commented Dec 12, 2016 at 12:14

1 Answer 1

4
$\begingroup$

You can use violin plots and logarithmic transformation (of course you should add some constant to avoid $log(0)$) to compare the distributions and their quantiles at different levels of some factor.

For the sake of illustration please see below zero-inflated data of the number of the cod parasite (A Beginner’s Guide to R, A.F. Zuur et al., 2009) in dependence of its sex:

df <- structure(list(Sex = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,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L, 2L, 2L, 2L, 2L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 10L, 
10L, 10L, 10L, 10L, 11L, 13L, 13L, 13L, 14L, 14L, 14L, 16L, 17L, 
17L, 18L, 18L, 18L, 19L, 20L, 20L, 30L, 34L, 36L, 40L, 42L, 45L, 
46L, 46L, 49L, 50L, 55L, 75L, 84L, 89L, 90L, 104L, 125L, 128L, 
257L)), class = "data.frame", row.names = c(1L, 2L, 3L, 4L, 5L, 
6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 
32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 
45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 
58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 
71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 
84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 
97L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 106L, 107L, 
108L, 109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 118L, 
119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L, 128L, 129L, 
130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 139L, 140L, 
141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 149L, 150L, 151L, 
152L, 153L, 154L, 155L, 156L, 157L, 158L, 159L, 160L, 161L, 162L, 
163L, 164L, 165L, 166L, 167L, 168L, 169L, 170L, 171L, 172L, 173L, 
174L, 175L, 176L, 177L, 178L, 179L, 180L, 181L, 182L, 183L, 184L, 
185L, 186L, 187L, 188L, 189L, 190L, 191L, 192L, 193L, 194L, 195L, 
196L, 197L, 198L, 199L, 200L, 201L, 202L, 203L, 204L, 205L, 206L, 
207L, 208L, 209L, 210L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 
218L, 219L, 220L, 221L, 222L, 223L, 224L, 225L, 226L, 227L, 228L, 
229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L, 237L, 238L, 239L, 
240L, 241L, 242L, 243L, 244L, 245L, 246L, 247L, 248L, 249L, 250L, 
251L, 252L, 253L, 254L, 255L, 256L, 257L, 258L, 259L, 260L, 261L, 
262L, 263L, 264L, 265L, 266L, 267L, 268L, 269L, 270L, 271L, 272L, 
273L, 274L, 275L, 276L, 277L, 278L, 279L, 280L, 281L, 282L, 283L, 
284L, 285L, 286L, 287L, 288L, 289L, 290L, 291L, 292L, 293L, 294L, 
295L, 296L, 297L, 298L, 299L, 300L, 301L, 302L, 303L, 304L, 305L, 
306L, 307L, 308L, 309L, 310L, 311L, 312L, 313L, 314L, 315L, 316L, 
317L, 318L, 319L, 320L, 321L, 322L, 323L, 324L, 325L, 326L, 327L, 
328L, 329L, 330L, 331L, 332L, 333L, 334L, 335L, 336L, 337L, 338L, 
339L, 340L, 341L, 342L, 343L, 344L, 345L, 346L, 347L, 348L, 349L, 
350L, 351L, 352L, 353L, 354L, 355L, 356L, 357L, 358L, 359L, 360L, 
361L, 362L, 363L, 364L, 365L, 366L, 367L, 368L, 369L, 370L, 371L, 
372L, 373L, 374L, 375L, 376L, 377L, 378L, 379L, 380L, 381L, 382L, 
383L, 384L, 385L, 386L, 387L, 388L, 389L, 390L, 391L, 392L, 393L, 
394L, 395L, 396L, 397L, 398L, 399L, 400L, 401L, 402L, 403L, 404L, 
405L, 406L, 407L, 408L, 409L, 410L, 411L, 412L, 413L, 414L, 415L, 
416L, 417L, 418L, 419L, 420L, 421L, 422L, 423L, 424L, 425L, 426L, 
427L, 428L, 429L, 430L, 431L, 432L, 433L, 434L, 435L, 436L, 437L, 
438L, 439L, 440L, 441L, 442L, 443L, 444L, 445L, 446L, 447L, 448L, 
449L, 450L, 451L, 452L, 453L, 454L, 455L, 456L, 457L, 458L, 459L, 
460L, 461L, 462L, 463L, 464L, 465L, 466L, 467L, 468L, 469L, 470L, 
471L, 472L, 473L, 474L, 475L, 476L, 477L, 478L, 479L, 480L, 481L, 
482L, 483L, 484L, 485L, 486L, 487L, 488L, 489L, 490L, 491L, 492L, 
493L, 494L, 495L, 496L, 497L, 498L, 499L, 500L, 501L, 502L, 503L, 
504L, 505L, 506L, 507L, 508L, 509L, 510L, 511L, 512L, 513L, 514L, 
515L, 516L, 517L, 518L, 519L, 520L, 521L, 522L, 523L, 524L, 525L, 
526L, 527L, 528L, 529L, 530L, 531L, 532L, 533L, 534L, 535L, 536L, 
537L, 538L, 539L, 540L, 541L, 542L, 543L, 544L, 545L, 546L, 547L, 
548L, 549L, 550L, 551L, 552L, 553L, 554L, 555L, 556L, 557L, 558L, 
559L, 560L, 561L, 562L, 563L, 564L, 565L, 566L, 567L, 568L, 569L, 
570L, 571L, 572L, 573L, 574L, 575L, 576L, 577L, 578L, 579L, 580L, 
581L, 582L, 583L, 584L, 585L, 586L, 587L, 588L, 589L, 590L, 591L, 
592L, 593L, 594L, 595L, 596L, 597L, 598L, 599L, 600L, 601L, 602L, 
603L, 604L, 605L, 606L, 607L, 608L, 609L, 610L, 611L, 612L, 613L, 
614L, 615L, 616L, 617L, 618L, 619L, 620L, 621L, 622L, 623L, 624L, 
625L, 626L, 627L, 628L, 629L, 630L, 631L, 632L, 633L, 634L, 635L, 
636L, 637L, 638L, 639L, 640L, 641L, 642L, 643L, 644L, 645L, 646L, 
647L, 648L, 649L, 650L, 651L, 652L, 653L, 654L, 655L, 656L, 657L, 
658L, 659L, 660L, 661L, 662L, 663L, 664L, 665L, 666L, 667L, 668L, 
669L, 670L, 671L, 672L, 673L, 674L, 675L, 676L, 677L, 678L, 679L, 
680L, 681L, 682L, 683L, 684L, 685L, 686L, 687L, 688L, 689L, 690L, 
691L, 692L, 693L, 694L, 695L, 696L, 697L, 698L, 699L, 700L, 701L, 
702L, 703L, 704L, 705L, 706L, 707L, 708L, 709L, 710L, 711L, 712L, 
713L, 714L, 715L, 716L, 717L, 718L, 719L, 720L, 721L, 722L, 723L, 
724L, 725L, 726L, 727L, 728L, 729L, 730L, 731L, 732L, 733L, 734L, 
735L, 736L, 737L, 738L, 739L, 740L, 741L, 742L, 743L, 744L, 745L, 
746L, 747L, 748L, 749L, 750L, 751L, 752L, 753L, 754L, 755L, 756L, 
757L, 758L, 759L, 760L, 761L, 762L, 763L, 764L, 765L, 766L, 767L, 
768L, 769L, 770L, 771L, 772L, 773L, 774L, 775L, 776L, 777L, 778L, 
779L, 780L, 781L, 782L, 783L, 784L, 785L, 786L, 787L, 788L, 789L, 
790L, 791L, 792L, 793L, 794L, 795L, 796L, 797L, 798L, 799L, 800L, 
801L, 802L, 803L, 804L, 805L, 806L, 807L, 808L, 809L, 810L, 811L, 
812L, 813L, 814L, 815L, 816L, 817L, 818L, 819L, 820L, 821L, 822L, 
823L, 824L, 825L, 826L, 827L, 828L, 829L, 830L, 831L, 832L, 833L, 
834L, 835L, 836L, 837L, 838L, 839L, 840L, 841L, 842L, 843L, 844L, 
845L, 846L, 847L, 848L, 849L, 850L, 851L, 852L, 853L, 854L, 855L, 
856L, 857L, 858L, 859L, 860L, 861L, 862L, 863L, 864L, 865L, 866L, 
867L, 868L, 869L, 870L, 871L, 872L, 873L, 874L, 875L, 876L, 877L, 
878L, 879L, 880L, 881L, 882L, 883L, 884L, 885L, 886L, 944L, 945L, 
946L, 947L, 948L, 949L, 950L, 951L, 952L, 953L, 954L, 955L, 956L, 
957L, 958L, 959L, 960L, 961L, 962L, 963L, 964L, 965L, 966L, 967L, 
968L, 969L, 970L, 971L, 972L, 973L, 974L, 975L, 976L, 977L, 978L, 
979L, 980L, 981L, 982L, 983L, 984L, 985L, 986L, 987L, 988L, 989L, 
990L, 991L, 992L, 993L, 994L, 995L, 996L, 997L, 998L, 999L, 1000L, 
1001L, 1002L, 1003L, 1004L, 1005L, 1006L, 1007L, 1008L, 1009L, 
1010L, 1011L, 1012L, 1013L, 1014L, 1015L, 1016L, 1017L, 1018L, 
1019L, 1020L, 1021L, 1022L, 1023L, 1024L, 1025L, 1026L, 1027L, 
1028L, 1029L, 1030L, 1031L, 1032L, 1033L, 1034L, 1035L, 1036L, 
1037L, 1038L, 1039L, 1040L, 1041L, 1042L, 1043L, 1044L, 1045L, 
1046L, 1047L, 1048L, 1049L, 1050L, 1051L, 1052L, 1053L, 1054L, 
1055L, 1056L, 1057L, 1058L, 1059L, 1060L, 1061L, 1062L, 1063L, 
1064L, 1065L, 1066L, 1067L, 1068L, 1069L, 1070L, 1071L, 1072L, 
1073L, 1074L, 1075L, 1076L, 1077L, 1078L, 1079L, 1080L, 1081L, 
1082L, 1083L, 1084L, 1085L, 1086L, 1087L, 1088L, 1089L, 1090L, 
1091L, 1092L, 1093L, 1094L, 1095L, 1096L, 1097L, 1098L, 1099L, 
1100L, 1101L, 1102L, 1103L, 1104L, 1105L, 1106L, 1107L, 1108L, 
1109L, 1110L, 1111L, 1112L, 1113L, 1114L, 1115L, 1116L, 1117L, 
1118L, 1119L, 1120L, 1121L, 1122L, 1123L, 1124L, 1125L, 1126L, 
1127L, 1128L, 1129L, 1130L, 1131L, 1132L, 1133L, 1134L, 1135L, 
1136L, 1137L, 1138L, 1139L, 1140L, 1141L, 1142L, 1143L, 1144L, 
1145L, 1146L, 1147L, 1148L, 1149L, 1150L, 1151L, 1152L, 1153L, 
1154L, 1155L, 1156L, 1157L, 1158L, 1159L, 1160L, 1161L, 1162L, 
1163L, 1164L, 1165L, 1166L, 1167L, 1168L, 1169L, 1170L, 1171L, 
1172L, 1173L, 1174L, 1175L, 1176L, 1177L, 1178L, 1179L, 1180L, 
1181L, 1182L, 1183L, 1184L, 1185L, 1186L, 1187L, 1188L, 1189L, 
1190L, 1191L, 1192L, 1193L, 1194L, 1195L, 1196L, 1197L, 1198L, 
1199L, 1200L, 1201L, 1202L, 1203L, 1204L, 1205L, 1206L, 1207L, 
1208L, 1209L, 1210L, 1211L, 1212L, 1213L, 1214L, 1215L, 1216L, 
1217L, 1218L, 1219L, 1220L, 1221L, 1222L, 1223L, 1224L, 1225L, 
1226L, 1227L, 1228L, 1229L, 1230L, 1231L, 1232L, 1233L, 1234L, 
1235L, 1236L, 1237L, 1238L, 1239L, 1240L, 1241L, 1242L, 1243L, 
1244L, 1245L, 1246L, 1247L, 1248L, 1249L, 1250L, 1251L, 1252L, 
1253L, 1254L))

Then using ggplot2 package together with logarithmic transformation $ln(x + 1)$ you can draw violin-plot and show quantiles:

library(ggplot2)
ggplot(df, aes(x = factor(Sex), y = log(Intensity + 1))) +
  geom_violin(draw_quantiles = c(.25, .5, .75, .95))

The result is: Violin plot

$\endgroup$
1
  • 1
    $\begingroup$ A square or cube root transformation works well too. Both allow you to skip the workaround of adding 1 before taking the log. Cube roots also work well with negative numbers. $\endgroup$
    – mkt
    Commented Sep 25, 2019 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.