How to boxplot already determined statistics with whiskers

15 views (last 30 days)
I have the mean, min, max, and std. values for many processed excel files. Each file has a date associated with it and I am try to plot these values in a box plot. The x-axis = the dates that I have carried around and are displayed with xticklabel and y-axis = the data including mean, min, max, and std. Right now I have plotted them into a scatter plot but need to have it in a box plot.
[num, text] = xlsread('5V.xls','PDU_OP');
mean = num(:,1);
min = num(:,3);
max = num(:,4);
[a, ~] = size(mean);
x = linspace(1,a,a);
figure(4)
scatter(x, max, 'b', 'MarkerFaceColor','b')
hold on
scatter(x, mean, 'r', 'MarkerFaceColor','r')
scatter(x, min, 'g', 'MarkerFaceColor','g')
set(gca,'XTick',1:a,'XTickLabel', text(:,1));
legend('max','mean','min','location','southeast');
title('PDU\_OP')
xlabel('Date/Time')
ylabel('Voltage');
grid on
My code reads a sheet on an excel file consisting of the dates (text, which is sized and formated to the plot to account for the exact number of data rows in the excel file and are assigned to my xticklabel as text(:,1)) and mean, min, max, std. values (num, which are assigned separately because scatter plots won't allow multiple data plotting only plot overlaying, done by 'hold on')
It being a scatter plot I cannot show the std. but it would be num(:,2). I would like to take the 4 details for each date of data and plot them with a box plot.

Accepted Answer

Matt Cohen
Matt Cohen on 31 Jul 2015
Hi Calabrese,
I understand that you are attempting to make a series of box plots over time with statistics of data (mean, minimum, maximum, and standard deviation) from Excel files. Unfortunately, this is not enough information to create a box plot. Box and whisker plots are produced from the entirety of the data, not just the statistics. The plot displays the median; the first and third quartiles; and the minimum and maximum values, ignoring outliers.
The MATLAB function that you would like to use here is "boxplot". This function takes in a data matrix X, where each column of data produces a box in the box plot. In order to be able to use "boxplot", you would need to provide all of the data collected for each date; then, the function would compute the appropriate statistics and display the corresponding boxes for each date.
I hope this helps.
Matt

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!