0
$\begingroup$

I have three sets of data which are collected in Jan, Feb and Mar respectively. I would like to make a box plot to show the monthly variations. As the data volume is large, I classified the data into different classes (from 0 to 10) first rather than using BoxWhiskerChart directly. The first column in the following table is the value and 2nd to 4th column are the number of counts from 0 to 1, 1 to 2, 2 to 3, etc.

Based on these table, is it possible to make a box plot for each month in Mathematica? or I still need to use BoxWhiskerChart with the unclassified dataset?

Many thanks in advance.

{{"", "Jan", "Feb", "Mar"}, {0, 0., 1.1, 6.7}, {1, 20., 80.8,813.}, {2, 846.1, 8833.1, 4681.2}, {3, 5131.5, 15486.1,12068.1}, {4, 229821., 89304.5, 48368.2}, {5, 8784.6, 8846.7,187924.}, {6, 515., 8799.1, 46853.9}, {7, 137.8, 154.8, 4874.1}, {8,0., 666.7, 974.5}, {9, 0., 70.9, 897.9}, {10, 0., 880., 79.1}}

enter image description here

$\endgroup$
2
  • 3
    $\begingroup$ The documentation for BoxWhiskerChart describes how to create a single chart with multiple datasets. How did that not work for you? If as you say you have lots of data, then boxplots are not as informative as nonparametric density estimates (SmoothKernelDistribution) or even histograms. (And if the 2nd to 4th columns are counts, why are not all of those values integers?) $\endgroup$
    – JimB
    Feb 13, 2019 at 14:06
  • $\begingroup$ The data is about number of rain drop. The sampling was integer at first but then converted to density per volume per unit length, so became real numbers. $\endgroup$
    – wkong
    Feb 14, 2019 at 1:49

1 Answer 1

1
$\begingroup$

As JimB suggested, using BoxWhiskerChart or Histogram on original data (or on a random sample of it) is the better approach.

If you have to use the summary table to create a BoxWhiskerChart you can

  1. construct WeightedData objects using the frequencies and bin values,
  2. create distributions using SmoothKernelDistribution on the weighted data objects,
  3. create a new sample with large enough sample size from each distribution created above,
  4. use BoxWhiskerChart or DistributionChart with the constructed data set.

table = {{"", "Jan", "Feb", "Mar"}, {0, 0., 1.1, 6.7}, {1, 20., 80.8, 813.},
 {2, 846.1, 8833.1, 4681.2}, {3, 5131.5, 15486.1, 12068.1}, {4, 229821., 89304.5, 48368.2}, 
 {5, 8784.6, 8846.7, 187924.}, {6, 515., 8799.1, 46853.9}, {7, 137.8, 154.8, 4874.1}, 
 {8, 0., 666.7, 974.5}, {9, 0., 70.9, 897.9}, {10, 0., 880., 79.1}};

labels = Rest@table[[1]];
data = Rest@table;
values = data[[All, 1]];
weights = Transpose[data[[All, 2 ;;]]];
weighteddata = WeightedData[values, #] & /@ weights;
data2 = RandomVariate[SmoothKernelDistribution[#], 500] & /@ weighteddata; 

BoxWhiskerChart[data2, ChartStyle -> 97, ChartLabels -> labels]

enter image description here

DistributionChart[data2, ChartElementFunction -> "BoxWhisker", ChartLabels -> labels]

enter image description here

DistributionChart[weighteddata, ChartElementFunction -> "Density", ChartLabels -> labels] 

enter image description here

$\endgroup$

Your Answer

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

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